-
Notifications
You must be signed in to change notification settings - Fork 0
Examples and Acceptance Tests - Separate Created/Published Data from Default Data Store #71
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an ExampleContext class that creates an isolated data store environment for examples, preventing example data from polluting the production data store. The implementation uses environment variables to configure a separate Discovery Service instance with a unique cluster ID.
- Adds
ExampleContextclass with context manager support for setting up and tearing down example-specific environments - Updates all notebook examples and the standalone
overview.pyto use the new example context - Adds
example_data/directory to.gitignorefor storing example-specific data
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/common/_example_context.py | New class that manages example-specific Discovery Service and Data Store configuration via environment variables |
| examples/common/init.py | Exports the ExampleContext class for use in examples |
| examples/notebooks/initialize_example_notebook.py | Helper script for initializing example context in Jupyter notebooks |
| examples/overview/src/overview.py | Updated to use ExampleContext as a context manager |
| examples/notebooks/voltage-regulator/publish_waveforms.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/query/query_metadata.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/query/query_measurements.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/query/publish_sample_data.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/overview/publish_measurement.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/custom-metadata/custom_metadata.ipynb | Added initialization and cleanup calls for example context |
| examples/notebooks/alias/alias.ipynb | Added initialization and cleanup calls for example context |
| .gitignore | Added examples/example_data/ to prevent committing example-generated data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Renamed ExampleContext to DataStoreContext. - Generate a cluster ID from a hash of the directory path being used. - Do not terminate the Discovery Service (with the particular cluster ID) when the DataStoreContext exits. - Remove unnecessary code for making directories (the service will handle this for us)
…nced by both examples and tests
This reverts commit 51e1bf3.
dixonjoel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relatively minor feedback. Generally looks good.
This reverts commit 5b7dda0.
… (and implicitly, discovery client)
What does this Pull Request accomplish?
This set of changes enables the examples and acceptance tests present in the
datastore-pythonrepo to publish data/metadata to a running Data Store Service while keeping that data separate from production data/metadata that is being published through typical usage of the client API.Note that these changes are reliant upon a change to
DiscoveryClientinni-apis-pythonto be aware of the existing Cluster ID environment variable and use it to help detect the appropriate Discovery Service (with that ID).Implementation
This set of changes centers around the addition of a
DataStoreContextclass that initializes the necessary state to ensure that aDataStoreClientorMetadataStoreClientthat is exercised within that context interacts with a Discovery Service + Data Store Service that is publishing data to an isolated location separate from the typical location for production data. ThisDataStoreContextis leveraged both byexamplesandtests, so it has been added in a separate, newutilitiestop-level folder that defines a package that is referenced as adevdependency of both the repo's overallpyproject.toml(used for tests and notebooks) and thepyproject.tomlof each individual, standalone example (overviewandsystem).The
DataStoreContextaccomplishes this by setting an environment variable that instructs the Discovery Service to launch with a particular cluster ID, ensuring that the Discovery Service + Data Store Service that is used in the example/test is not the 'default' instance that could perhaps already be running on the machine due to another client's usage. TheDataStoreContextalso sets environment variables configuring the behavior of the Data Store Service. (These environment variables are inherited by the Data Store Service process that the Discovery Service launches.) TheDataStoreContextalso implements a Context Manager pattern to allow this particular environment to be easily stood up and torn down via awithstatement.DataStoreContextas part of beginning example executionDataStoreContextfor the body of the example's executionDataStoreContextas a module-level test fixture for test executionBy default, the
DataStoreContextwill redirect Data Store Service output to atemp_datafolder in the root of the repo. This location has been added to.gitignore. It is also configurable as a parameter of theDataStoreContext.Why should this Pull Request be merged?
This set of changes helps prevent unnecessary pollution of the production data store with example or test data.
What testing has been done?
temp_dataand do not modify the production data store.temp_dataand do not modify the production data store.utilitiesfolder, similar to what is already in place forexamples.