Workflow downloader script#59
Open
mayamkay wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.pyto 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")) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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