Skip to content

Workflow downloader script#59

Open
mayamkay wants to merge 2 commits into
mainfrom
download-workflow-code-programatically
Open

Workflow downloader script#59
mayamkay wants to merge 2 commits into
mainfrom
download-workflow-code-programatically

Conversation

@mayamkay

@mayamkay mayamkay commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new script which can be used to downloads all scripts from a Civis Platform workflow into a local folder, preserving the workflow's structure. Useful when you want to audit, version-control, or share the code behind a workflow without clicking through Platform one script at a time.

Because this downloads code locally you actually need to run it locally on your laptop using the Civis API key instead of running it in platform

The script was used to download the GPAP code and was tested while working on that project

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a small Python utility under python/get_platform_workflow_code/ to export the code behind a Civis Platform workflow (including sub-workflows) to a local directory, with accompanying usage documentation.

Changes:

  • Introduces get_platform_workflow_code.py to traverse the latest workflow execution and download step scripts recursively into a folder structure.
  • Adds a README describing setup, expected output layout, and usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/get_platform_workflow_code/get_platform_workflow_code.py New script that fetches workflow execution tasks and writes retrieved script sources to disk.
python/get_platform_workflow_code/README.md Documentation for installing dependencies, configuring API key, and running the downloader.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +12
Usage:
pip install civis
export CIVIS_API_KEY="your_api_key"
python download_workflow_scripts.py

Comment on lines +166 to +176
header = (
f"# Step {step_num}: {task_name}\n"
f"# Workflow ID: {workflow_id} | Execution ID: {execution_id}\n"
f"# Job ID: {job_id} | Job name: {job_name}\n" + "#" + "─" * 68 + "\n\n"
)

filename = f"{step_label}.{ext}"
filepath = os.path.join(output_dir, filename)
with open(filepath, "w", encoding="utf-8") as f:
f.write(header + (content or "# (empty source)\n"))

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