Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
check_nims:
name: Check NIMS
uses: ./.github/workflows/check_nims.yml
check_nims_docs:
name: Check NIMS docs
uses: ./.github/workflows/check_nims_docs.yml
check_nimg:
name: Check NIMG
uses: ./.github/workflows/check_nimg.yml
Expand Down
30 changes: 14 additions & 16 deletions .github/workflows/check_nimg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
jobs:
check_nimg:
name: Check NIMG
runs-on: ubuntu-latest
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, 3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
# Set the working-directory for all steps in this job.
Expand All @@ -18,33 +23,26 @@ jobs:
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Check for lock changes (ni-measurement-plugin-sdk-generator)
run: poetry check --lock
- name: Cache virtualenv (ni-measurement-plugin-sdk-generator)
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache
- name: Analyze generator
uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
with:
path: packages/generator/.venv
key: ni-measurement-plugin-sdk-generator-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/generator/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-generator
run: poetry install -v
- name: Lint ni-measurement-plugin-sdk-generator
run: poetry run ni-python-styleguide lint
- name: Mypy static analysis (ni-measurement-plugin-sdk-generator, Linux)
run: poetry run mypy
- name: Mypy static analysis (ni-measurement-plugin-sdk-generator, Windows)
run: poetry run mypy --platform win32
project-directory: packages/generator
- name: Bandit security checks (ni-measurement-plugin-sdk-generator, example_renders)
run: poetry run bandit -c pyproject.toml -r ni_measurement_plugin_sdk_generator tests/test_assets/example_renders
- name: Generate gRPC stubs
if: matrix.python-version == '3.9'
run: |
find tests/utilities/measurements/non_streaming_data_measurement/_stubs -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
poetry run python scripts/generate_grpc_stubs.py
- name: Check for out-of-date gRPC stubs
if: matrix.python-version == '3.9'
run: git diff --exit-code
- name: Revert gRPC stubs
if: matrix.python-version == '3.9'
run: |
git clean -dfx tests/utilities/measurements/non_streaming_data_measurement/_stubs
git restore tests/utilities/measurements/non_streaming_data_measurement/_stubs
62 changes: 15 additions & 47 deletions .github/workflows/check_nims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
jobs:
check_nims:
name: Check NIMS
runs-on: ubuntu-latest
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, 3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
# Set the working-directory for all steps in this job.
Expand All @@ -20,64 +25,27 @@ jobs:
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Check for lock changes (ni-measurement-plugin-sdk-service)
run: poetry check --lock

# ni-measurement-plugin-sdk-service, all extras
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, all extras)
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: restore-nims-all-extras
- name: Analyze generator
uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
with:
path: packages/service/.venv
key: ni-measurement-plugin-sdk-service-all-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/service/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-service (all extras)
run: poetry install -v --all-extras
- name: Save cached virtualenv (ni-measurement-plugin-sdk-service, all extras)
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
if: steps.restore-nims-all-extras.outputs.cache-hit != 'true'
with:
path: packages/service/.venv
key: ${{ steps.restore-nims-all-extras.outputs.cache-primary-key }}
- name: Lint ni-measurement-plugin-sdk-service
run: poetry run ni-python-styleguide lint
- name: Mypy static analysis (ni-measurement-plugin-sdk-service, Linux)
run: poetry run mypy
- name: Mypy static analysis (ni-measurement-plugin-sdk-service, Windows)
run: poetry run mypy --platform win32
project-directory: packages/service
install-args: --all-extras
- name: Bandit security checks (ni-measurement-plugin-sdk-service)
run: poetry run bandit -c pyproject.toml -r ni_measurement_plugin_sdk_service

# ni-measurement-plugin-sdk-service, all extras, docs
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, all extras, docs)
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: restore-nims-all-extras-docs
with:
path: packages/service/.venv
key: ni-measurement-plugin-sdk-service-all-extras-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/service/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-service (all extras, docs)
run: poetry install -v --all-extras --with docs
- name: Save cached virtualenv (ni-measurement-plugin-sdk-service, all extras, docs)
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
if: steps.restore-nims-all-extras-docs.outputs.cache-hit != 'true'
with:
path: packages/service/.venv
key: ${{ steps.restore-nims-all-extras-docs.outputs.cache-primary-key }}
- name: Build docs and check for errors/warnings
run: |
rm -rf docs
mkdir -p docs
poetry run sphinx-build _docs_source docs -b html -W
- name: Revert docs
run: rm -rf docs
- name: Generate gRPC stubs
if: matrix.python-version == '3.9'
run: |
find tests/utilities/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
poetry run python scripts/generate_grpc_stubs.py
- name: Check for out-of-date gRPC stubs
if: matrix.python-version == '3.9'
run: git diff --exit-code
- name: Revert gRPC stubs
if: matrix.python-version == '3.9'
run: |
git clean -dfx tests/utilities/stubs/
git restore tests/utilities/stubs/
33 changes: 33 additions & 0 deletions .github/workflows/check_nims_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check NIMS Docs

on:
workflow_call:
workflow_dispatch:

jobs:
check_nims:
name: Check NIMS Docs
runs-on: ubuntu-latest
defaults:
run:
# Set the working-directory for all steps in this job.
working-directory: ./packages/service
steps:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Install ni-measurement-plugin-sdk-service (all extras, docs)
run: poetry install -v --all-extras --with docs
- name: Build docs and check for errors/warnings
run: |
rm -rf docs
mkdir -p docs
poetry run sphinx-build _docs_source docs -b html -W
- name: Revert docs
run: rm -rf docs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@

_PREFIX = "MEASUREMENT_PLUGIN"

# Create the config instance - always available for imports
_config = AutoConfig(str(get_dotenv_search_path()))

if TYPE_CHECKING:
# Work around decouple's lack of type hints.
# Work around decouple's lack of type hints by redefining the type
_T = TypeVar("_T")

def _config(
def __config_stub(
option: str,
default: _T | Undefined = undefined,
cast: Callable[[str], _T] | Undefined = undefined,
) -> _T: ...

# Tell type checker this is the real signature
_config = __config_stub


# ----------------------------------------------------------------------
# NI Modular Instrument Driver Options
Expand Down
34 changes: 24 additions & 10 deletions packages/service/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ numpy = [
{ version = ">=2.1", python = "^3.13"},
]
bandit = { version = ">=1.7", extras = ["toml"] }
# Install traceloggingdynamic on Linux for type checking.
traceloggingdynamic = { version = ">=1.0", platform = "linux" }
# Install traceloggingdynamic on Linux and MacOS for type checking.
traceloggingdynamic = [
{ version = ">=1.0", platform = "linux" },
{ version = ">=1.0", platform = "darwin" },
]

[tool.poetry.group.docs]
optional = true
Expand Down
Loading