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

Add an advanced dynamic_study_prefix field to manifests. #309

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

mikix
Copy link
Contributor

@mikix mikix commented Oct 24, 2024

This will allow a study to provide a Python file that accepts study options and generates an appropriate study prefix.

It's largely targeted at the data_metrics study, but might have application elsewhere.

Checklist

  • Consider if documentation in docs/ needs to be updated
    • If you've changed the structure of a table, you may need to run generate-md
    • If you've added/removed core study fields that not in US Core, update our list of those in core-study-details.md
  • Consider if tests should be added
  • Update template repo if there are changes to study configuration in manifest.toml

Copy link

github-actions bot commented Oct 24, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2257 2248 100% 90% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cumulus_library/actions/builder.py 100% 🟢
cumulus_library/builders/counts.py 100% 🟢
cumulus_library/cli.py 100% 🟢
cumulus_library/studies/core/count_core.py 100% 🟢
cumulus_library/study_manifest.py 100% 🟢
TOTAL 100% 🟢

updated for commit: 761773a by action🐍

Comment on lines -432 to +457
c_arg = c_arg.split(":", 2)
c_arg = c_arg.split(":", 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I always make this mistake (and might have made this one?) - it's number of splits, not number of parts.

This will allow a study to provide a Python file that accepts study
options and generates an appropriate study prefix.

It's largely targeted at the data_metrics study, but might have
application elsewhere.
Comment on lines -17 to -20
if study_prefix is None:
# This slightly wonky approach will give us the path of the
# directory of a class extending the CountsBuilder
study_path = Path(sys.modules[self.__module__].__file__).parent
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this whole chunk of logic to prepare_queries and just used the existing manifest that it sends down, rather than trying to re-discover the manifest and its options.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense, i think this pre-dates a lot of that infra.

Comment on lines +145 to +148
else:
# Add the prefix for them (helpful in dynamic prefix cases where the prefix
# is not known ahead of time)
export_table_list.append(f"{self.get_study_prefix()}__{table}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a notable change - this allows a study author to do:

[export_config]
export_tables = [
  "meta_version",
]

without a prefix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting - I don't think we should encourage that, though. We don't have to change the logic, but let's just not recommend it.


These features are for very narrow and advanced use cases,
designed for internal project studies (like `core`, `discovery`, or `data_metrics`).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i'm not in love with 'internal project studies', though i don't have a better idea off the top of my head.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah fair, I wasn't sure what phrase to use.

Comment on lines -17 to -20
if study_prefix is None:
# This slightly wonky approach will give us the path of the
# directory of a class extending the CountsBuilder
study_path = Path(sys.modules[self.__module__].__file__).parent
Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense, i think this pre-dates a lot of that infra.

Comment on lines +145 to +148
else:
# Add the prefix for them (helpful in dynamic prefix cases where the prefix
# is not known ahead of time)
export_table_list.append(f"{self.get_study_prefix()}__{table}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting - I don't think we should encourage that, though. We don't have to change the logic, but let's just not recommend it.

@mikix mikix marked this pull request as ready for review October 25, 2024 15:54
@mikix mikix merged commit f131f24 into main Oct 25, 2024
3 checks passed
@mikix mikix deleted the mikix/dynamic-prefix branch October 25, 2024 15:54
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.

2 participants