Skip to content

refactor: ♻️ download field metadata with pytask#153

Open
martonvago wants to merge 18 commits into
mainfrom
feat/pytask-download-field-metadata
Open

refactor: ♻️ download field metadata with pytask#153
martonvago wants to merge 18 commits into
mainfrom
feat/pytask-download-field-metadata

Conversation

@martonvago

Copy link
Copy Markdown
Collaborator

Description

This PR sets up pytask and downloads the data dict from REDCap. As we will be downloading other metadata as well, I'm calling it field metadata because it contains metadata about all fields in REDCap.

Related to #97

Needs a thorough review.

Checklist

  • Ran just run-all

env_key="REDC_CPH_API_KEY", url="https://redcap.regionh.dk/api/"
)
Odense = APIConfig(env_key="REDC_ODN_API_KEY", url="https://redcap.sdu.dk/api/")
Test = APIConfig(env_key="TEST_API_KEY", url="https://redcap.au.dk/api/")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can this live here for testing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we don't want to keep passing the paths around that declare task dependencies, we can move them into a data catalog

Comment on lines +17 to +21
def task_download_field_metadata(
field_metadata_path: Annotated[Path, Product] = BLD_REDCAP / "field_metadata.json",
) -> None:
"""Download field metadata to `BLD_REDCAP`."""
download_redcap_metadata(field_metadata_path, "metadata")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As we will be downloading other metadata as well, I'm calling this field metadata because it contains metadata about all fields in REDCap.

@martonvago martonvago moved this from Todo to In review in Data development Jul 2, 2026
@martonvago martonvago marked this pull request as ready for review July 2, 2026 18:36
@martonvago martonvago requested a review from a team as a code owner July 2, 2026 18:36

@martonvago martonvago Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe this is a good place to discuss the main issue/question I've run into with pytask so far: download tasks declare that they produce a file or files. If that file is unchanged, they won't rerun automatically when the pipeline is run with uv run pytask. We can use the --force flag on the CLI to get around this. Is that a workable solution or should I look for another way?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I also put up the changes for pulling out common logic separately as #154 because I wasn't sure how it was most helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant