Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ classifiers = [
]
description = " Python alternative to creating and running argo workflows in the Data Analysis Platform"
dependencies = [
"requests",
"gql",
"aiohttp",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
Expand Down
35 changes: 35 additions & 0 deletions src/python_interface_to_workflows/submit_to_graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport


def submit_to_graphql():
transport = AIOHTTPTransport(
url="https://staging.workflows.diamond.ac.uk/graphql",
headers={"Authorization": "Bearer "}, # after Bearer = access token
)
client = Client(
transport=transport,
fetch_schema_from_transport=True,
)
mutation = gql("""
mutation SubmitDivision {
submitWorkflowTemplate(
name: "division"
visit: {
proposalCode: "ks",
proposalNumber: 10000,
number: 3
}
parameters: {
numinput: "19",
numdivisor: "10"
}
){
name
}
}
""")
result = client.execute(mutation)
visit = "ks10000-3/c"
name = str(result["submitWorkflowTemplate"]["name"])
print(f"Job '{visit}-{name}' submitted.")
14 changes: 14 additions & 0 deletions tests/test_submit_to_graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from unittest.mock import MagicMock, patch

from python_interface_to_workflows.submit_to_graphql import submit_to_graphql


@patch("python_interface_to_workflows.submit_to_graphql.Client")
def test_submit_to_graphql(mock_client: MagicMock):
mock_instance = MagicMock()
mock_client.return_value = mock_instance
mock_instance.execute.return_value = {
"submitWorkflowTemplate": {"name": "workflow123"}
}
submit_to_graphql()
mock_instance.execute.assert_called_once()
Loading
Loading