Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version checking to warn that version is deprecated and error if there is no .serviceconfig version #911

Merged
merged 9 commits into from
Sep 24, 2024

Conversation

dixonjoel
Copy link
Collaborator

What does this Pull Request accomplish?

Fixes #908
This gives a warning if the 'version' parameter of MeasurementService is used. It also errors if there is a 'version' parameter, but no 'version' in the .serviceconfig file. The rule is if you pass a 'version' parameter, you must have the same 'version' in the .serviceconfig file.

Why should this Pull Request be merged?

Gives clearer guidance on the latest state of the version parameters.

What testing has been done?

Existing tests plus added one test to verify a RuntimeError in the case where there is a 'version' parameter passed but no version in the .serviceconfig file.

…ure that there is a version in the .serviceconfig file
Copy link

github-actions bot commented Sep 22, 2024

Test Results

    40 files  ± 0      40 suites  ±0   50m 52s ⏱️ + 2m 39s
   694 tests + 5     694 ✅ + 6      0 💤 ±0  0 ❌  - 1 
16 860 runs  +70  15 790 ✅ +71  1 070 💤 ±0  0 ❌  - 1 

Results for commit 72efbd5. ± Comparison against base commit 10328bb.

This pull request removes 2 and adds 7 tests. Note that renamed tests count towards both.
tests.unit.test_service ‑ test___service_config___create_measurement_service___service_info_matches_service_config[example.v1.serviceconfig--provided_interfaces1-provided_annotations1]
tests.unit.test_service ‑ test___service_config___create_measurement_service_with_version___version_is_used[example.v1.serviceconfig-2.0.1]
tests.acceptance.test_client_generator ‑ test___non_streaming_measurement___create_client___render_without_mypy_error
tests.unit.test_measurement_client ‑ test___enum_annotations___validate_and_transform_enum_annotations___returns_expected_enum_annotations[{"DC Volts": 0, "2-Wire Resistance": 1, "5 1/2": 2}-{"DC_Volts": 0, "k_2_Wire_Resistance": 1, "k_5_1_2": 2}]
tests.unit.test_measurement_client ‑ test___enum_annotations___validate_and_transform_enum_annotations___returns_expected_enum_annotations[{"NONE": 0, "RED": 1, "GREEN": 2}-{"NONE": 0, "RED": 1, "GREEN": 2}]
tests.unit.test_measurement_client ‑ test___invalid_enum_annotations___validate_and_transform_enum_annotations___raises_invalid_enum_value_error
tests.unit.test_service ‑ test___service_config___create_measurement_service___service_info_matches_service_config[example.v1.serviceconfig-1.0.1-provided_interfaces1-provided_annotations1]
tests.unit.test_service ‑ test___service_config___create_measurement_service_with_version___service_config_has_no_version
tests.unit.test_service ‑ test___service_config___create_measurement_service_with_version___version_is_used[example.v1.serviceconfig-1.0.1]

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@nick-beer nick-beer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - assuming someone else will grant explicit approval for these changes.

@bkeryan bkeryan merged commit 113b166 into main Sep 24, 2024
17 checks passed
@bkeryan bkeryan deleted the users/jdixon/update-version-checking branch September 24, 2024 22:13
bkeryan pushed a commit that referenced this pull request Sep 24, 2024
…if there is no .serviceconfig version (#911)

* Update version checking to warn that version is deprecated and to ensure that there is a version in the .serviceconfig file

* Fix lint error

* Update error message to mention version field in .serviceconfig

* Fix assert

* Fix lint errors

* Remove RuntimeError

* Use empty string

* Fix test to not expect RuntimeError

* Fix formatting

(cherry picked from commit 113b166)
Comment on lines +449 to +456
def test___service_config___create_measurement_service_with_version___service_config_has_no_version(
test_assets_directory: pathlib.Path,
):
measurement_service = MeasurementService(
service_config_path=test_assets_directory / "example.NoVersion.serviceconfig",
version="2.0.1",
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are generating warnings:

============================== warnings summary ===============================
tests/unit/test_service.py::test___service_config___create_measurement_service_with_version___version_differs_from_service_config
tests/unit/test_service.py::test___service_config___create_measurement_service_with_version___service_config_has_no_version
tests/unit/test_service.py::test___service_config___create_measurement_service_with_version___version_is_used[example.serviceconfig-1.0.1]
tests/unit/test_service.py::test___service_config___create_measurement_service_with_version___version_is_used[example.v1.serviceconfig-1.0.1]
  D:\a\measurement-plugin-python\measurement-plugin-python\packages\service\ni_measurement_plugin_sdk_service\measurement\service.py:222: DeprecationWarning: The 'version' constructor parameter is deprecated. Specify the version using the 'version' field in the .serviceconfig file instead.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: D:\a\measurement-plugin-python\measurement-plugin-python\packages\service\test_results\nims-windows-latest-py3.9-all-extras.xml -

Fixed in #942

bkeryan pushed a commit that referenced this pull request Sep 26, 2024
…if there is no .serviceconfig version (#911)

* Update version checking to warn that version is deprecated and to ensure that there is a version in the .serviceconfig file

* Fix lint error

* Update error message to mention version field in .serviceconfig

* Fix assert

* Fix lint errors

* Remove RuntimeError

* Use empty string

* Fix test to not expect RuntimeError

* Fix formatting

(cherry picked from commit 113b166)
bkeryan added a commit that referenced this pull request Sep 26, 2024
…ion is deprecated and error if there is no .serviceconfig version (#935)

Update version checking to warn that version is deprecated and error if there is no .serviceconfig version (#911)

* Update version checking to warn that version is deprecated and to ensure that there is a version in the .serviceconfig file

* Fix lint error

* Update error message to mention version field in .serviceconfig

* Fix assert

* Fix lint errors

* Remove RuntimeError

* Use empty string

* Fix test to not expect RuntimeError

* Fix formatting

(cherry picked from commit 113b166)

Co-authored-by: Joel Dixon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MeasurementService should provide more guidance about moving version number to the .serviceconfig file
3 participants