Skip to content

Commit

Permalink
try to hit dockstore
Browse files Browse the repository at this point in the history
  • Loading branch information
nikellepetrillo committed Dec 12, 2024
1 parent 029e160 commit c43613a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_illumina_genotyping_array.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Fetch Dockstore Workflow ID
run: |
python scripts/dockstore_api/fetch_dockstore_id.py $DOCKSTORE_TOKEN github.com%2Fbroadinstitute%2Fwarp%2FIlluminaGenotypingArray BIOWORKFLOW np_jw_test_illumina_genotyping_arrays
python scripts/dockstore_api/fetch_dockstore_commit.py $DOCKSTORE_TOKEN github.com%2Fbroadinstitute%2Fwarp%2FIlluminaGenotypingArray BIOWORKFLOW np_jw_test_illumina_genotyping_arrays
env:
##TODO NEED TO ADD DOCKSTORE_TOKEN FOR SERVICE ACCOUNT##
DOCKSTORE_TOKEN: ${{ secrets.DOCKSTORE_TOKEN }}
Expand Down
62 changes: 62 additions & 0 deletions scripts/dockstore_api/fetch_dockstore_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import requests
import sys

def fetch_workflow_and_version_ids(token, repository, subclass, version_name):
url = f"https://dockstore.org/api/workflows/path/workflow/{repository}/published"
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/json",
}

response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()

# Extract workflow and version IDs
workflow_id = data.get("id")
version_id = next(
(version["id"] for version in data.get("workflowVersions", [])
if version["name"] == version_name),
None
)

if not workflow_id or not version_id:
raise ValueError("Workflow ID or Version ID could not be found.")

return workflow_id, version_id

def fetch_commit_id(token, workflow_id, version_id):
url = f"https://dockstore.org/api/workflows/{workflow_id}/workflowVersions/{version_id}"
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/json",
}

response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()

# Extract commit ID
commit_id = data.get("commitID")
if not commit_id:
raise ValueError("Commit ID could not be found.")

return commit_id

if __name__ == "__main__":
if len(sys.argv) != 5:
print("Usage: python fetch_dockstore_commit.py <token> <repository> <subclass> <version_name>")
sys.exit(1)

_, token, repository, subclass, version_name = sys.argv

try:
workflow_id, version_id = fetch_workflow_and_version_ids(token, repository, subclass, version_name)
print(f"Workflow ID: {workflow_id}")
print(f"Version ID: {version_id}")

commit_id = fetch_commit_id(token, workflow_id, version_id)
print(f"Commit ID: {commit_id}")

except Exception as e:
print(f"Error: {e}")
40 changes: 0 additions & 40 deletions scripts/dockstore_api/fetch_dockstore_id.py

This file was deleted.

0 comments on commit c43613a

Please sign in to comment.