Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: upload workflows to WorkflowHub via API #129

Open
simleo opened this issue Aug 25, 2021 · 1 comment
Open

Testing: upload workflows to WorkflowHub via API #129

simleo opened this issue Aug 25, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@simleo
Copy link
Member

simleo commented Aug 25, 2021

Now that submitting RO-Crates is supported by the WorkflowHub API, we can programmatically upload the workflows we need for LM testing and get rid of tests/config/registries/seek/data.tar.gz.

A workflow can be submitted as follows:

import requests
from pathlib import Path

crate_archive = "/tmp/crate.zip"
hub_url = "http://localhost:3000"
api_key = "???"
proj_id = "1"

# upload workflow
headers = {"authorization": f"Token {api_key}"}
with open(crate_archive, "rb") as f:
    payload = {
        "ro_crate": (Path(crate_archive).name, f),
        "workflow[project_ids][]": (None, proj_id)
    }
    r = requests.post(f"{hub_url}/workflows", headers=headers, files=payload)
r.raise_for_status()
    
# update access policy
wf_id = r.json()["data"]["id"]
headers.update({
    "Content-type": "application/vnd.api+json",
    "Accept": "application/vnd.api+json",
    "Accept-Charset": "ISO-8859-1",
})
payload = {
    "data": {
        "id": wf_id,
        "type": "workflows",
        "attributes": {
            "policy": {
                "access": "download",
                "permissions": [
                    {
                        "resource": {"id": proj_id, "type": "projects"},
                        "access": "edit"
                    }
                ]
            }
        }
    }
}
r = requests.patch(f"{hub_url}/workflows/{wf_id}", headers=headers, json=payload)
r.raise_for_status()

This requires a recent WorkflowHub image.

@simleo simleo added the enhancement New feature or request label Aug 25, 2021
@ilveroluca
Copy link
Member

This is relevant only for the LifeMonitor tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants