Skip to content

chore: 🔨 outline pytask flow for staging data#152

Closed
martonvago wants to merge 16 commits into
mainfrom
feat/pytask-flow
Closed

chore: 🔨 outline pytask flow for staging data#152
martonvago wants to merge 16 commits into
mainfrom
feat/pytask-flow

Conversation

@martonvago

Copy link
Copy Markdown
Collaborator

Description

This PR outlines how the pytask pipeline could be structured for staging data (see build.py). I pulled out some common code (dealing with the API, reading/writing JSON) to make the structure clearer.

I deliberately removed the implementation of the tasks to focus on where things should be saved and how the tasks should be organised. There is a working draft of the implementation on https://github.com/onlimit-study/feasibility-data/tree/feat/pytask-wip if it's helpful.

Closes #97

Needs a thorough review.

Checklist

  • Ran just run-all -- well, bits of it

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.

This is all stuff we had before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, there are too many things going on here in this PR. Can you start very small, with just a task for downloading the dictionary? Then build PRs from there that add one task at a time?

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 was thinking that seeing the whole flow with the function stubs is useful, but if not then sure!

@github-project-automation github-project-automation Bot moved this from Todo to In progress in Data development Jul 2, 2026
@lwjohnst86 lwjohnst86 changed the title feat: ✨ outline pytask flow for staging data chore: 🔨 outline pytask flow for staging data 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.

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 +30 to +39
def task_download_data(
raw_data_dir: Annotated[
Path,
DirectoryNode(root_dir=RAW_REDCAP, pattern="*.csv.gz"),
Product,
],
) -> None:
"""Download the latest data from all centers to `RAW_REDCAP/<timestamp>.csv.gz`."""
for center in [Center.Copenhagen]:
download_redcap_data(raw_data_dir, center)

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.

Some notes here:

  • Dealing with the different centers is a work in progress, but this is a nod in that direction
  • pytask doesn't have an "always run this task" option, so data download will only run on uv run pytask if the RAW_REDCAP folder is empty. We can force execution with e.g.
uv run pytask -k download_data --force
uv run pytask

@martonvago martonvago closed this Jul 2, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in Data development Jul 2, 2026
@martonvago

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #153

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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Set up pytask workflow to manage data pipeline

2 participants