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

service: Add MeasurementContext.reserve_session(s) #402

Merged
merged 36 commits into from
Sep 28, 2023

Conversation

bkeryan
Copy link
Collaborator

@bkeryan bkeryan commented Sep 22, 2023

What does this Pull Request accomplish?

ni-measurementlink-service:

  • Add reserve_session and reserve_sessions methods to the public MeasurementContext class
    • These have the same signature as in SessionManagementClient, except the pin_map_context parameter is removed
  • Add a session_management_client property to the public MeasurementService class
  • Enable the MeasurementContext to get a reference to the owning MeasurementService
    • Add an internal _measurement_service property to the public MeasurementContext class
    • Pass an opaque owner to the internal GrpcService, GrpcServicer, and MeasurementServiceContext classes
    • When saving the owner as an object attribute, use a weak reference to avoid introducing a reference cycle

tests:

  • Add acceptance tests for session management
    • These use the real MeasurementLink session management and pin map services.
  • Add a pin_aware_measurement test service
  • Add a PinMapClient to the test utilities
    • This is an improved version of the one in _helpers.py: it can use the discovery client and gRPC channel pool.
    • In a separate PR, I would like to move this into a shipping package and delete the one in _helpers.py.
  • Add __init__.py files to the acceptance/integration/unit directories so that test_*.py names don't have to be unique.
  • Add unit tests for MeasurementContext

Why should this Pull Request be merged?

This is part of the updated session reservation API.

What testing has been done?

Ran poetry run pytest -v.
Updated nidmm_measurement to use the new APIs and manually tested.

@github-actions
Copy link

github-actions bot commented Sep 22, 2023

Test Results

     12 files  ±    0       12 suites  ±0   2m 34s ⏱️ -1s
   277 tests +  49     211 ✔️ +  12    66 💤 +  37  0 ±0 
3 312 runs  +588  2 504 ✔️ +144  808 💤 +444  0 ±0 

Results for commit eeae31c. ± Comparison against base commit c008f98.

♻️ This comment has been updated with latest results.

In Python 3.8, `weakref.ref` is just a `type` and lower-case `type`
doesn't support subscripting with this version. The fix is to use
`from __future__ import annotations` so that Python 3.8 doesn't try
to parse this type hint.

Also, use `ReferenceType` instead of `ref` in annotations, since it
looks more like a type. (It doesn't really matter because one is an
alias for the other.)
@bkeryan bkeryan force-pushed the users/bkeryan/context-reserve-sessions branch from 10dfe61 to e6b46b8 Compare September 28, 2023 00:16
@bkeryan bkeryan changed the base branch from main to users/bkeryan/feature-toggles September 28, 2023 00:17
Base automatically changed from users/bkeryan/feature-toggles to main September 28, 2023 15:30
@bkeryan bkeryan requested a review from dixonjoel September 28, 2023 16:30
@bkeryan bkeryan merged commit 06bf839 into main Sep 28, 2023
17 checks passed
@bkeryan bkeryan deleted the users/bkeryan/context-reserve-sessions branch September 28, 2023 20:58
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.

4 participants