Skip to content

feat: default database and collection in MetadataDbClient #152

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

Merged
merged 3 commits into from
Jun 24, 2025

Conversation

helen-m-lin
Copy link
Collaborator

@helen-m-lin helen-m-lin commented Jun 24, 2025

closes #151

Default version is v1, which uses metadata_index/data_assets:

docdb_client = MetadataDbClient(
    host="api.allenneuraldynamics-test.org",
)

v2 uses new metadata_index_v2/data_assets.

docdb_client = MetadataDbClient(
   host="api.allenneuraldynamics-test.org",
   version="v2"
)

@helen-m-lin helen-m-lin marked this pull request as ready for review June 24, 2025 18:34
@helen-m-lin helen-m-lin requested review from jtyoung84 and dbirman June 24, 2025 18:38
Copy link
Member

@dbirman dbirman left a comment

Choose a reason for hiding this comment

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

General comment: should we set this up so that it pulls from environment variables but has defaults in place? Like in the QC and metadata portals right now I use

API_GATEWAY_HOST = os.getenv("API_GATEWAY_HOST", "api.allenneuraldynamics-test.org")
DATABASE = os.getenv("DATABASE", "metadata_index")
COLLECTION = os.getenv("COLLECTION", "data_assets")

If we set up some generic env variable names here like "DATA_ACCESS_API_HOST", "_DB", and "_COLLECTION" here then in deployments we would have a no-code way of switching apps between dev/prod just from the aws param store. Same with version, could have a default in place, pull from an env variable when present, and still be user-settable for people who need to set it in their code directly.

@jtyoung84
Copy link
Contributor

We could potentially set something up where it searches for configuration settings in an env file or env vars, but I reckon we can do that in a future PR as a nice-to-have.

@helen-m-lin
Copy link
Collaborator Author

Yeah I agree it could be a useful addition. In the SSH client, we did something like that using pydantic_serttings.EnvSettingsSource. The current client does not use pydantic, so this might be better as part of future issue.


docdb_api_client = MetadataDbClient(
host=API_GATEWAY_HOST,
database=DATABASE,
collection=COLLECTION,
# database=DATABASE,
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to remove these comments and just make a note above on how to override the fields if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

@helen-m-lin helen-m-lin requested review from dbirman and jtyoung84 June 24, 2025 21:33
@helen-m-lin helen-m-lin merged commit a3e26e5 into dev Jun 24, 2025
3 checks passed
@helen-m-lin helen-m-lin deleted the feat-151-default-db-coll branch June 24, 2025 21:50
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.

MetadataDbClient default database and collection based on version
3 participants