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

return inputs in GET /jobs/<job_id>/inputs #32

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
SWOOP_SECRET_ACCESS_KEY: "${SWOOP_SECRET_ACCESS_KEY:-password}"
SWOOP_S3_ENDPOINT: "http://minio:9000"
SWOOP_BUCKET_NAME: "${SWOOP_BUCKET_NAME:-swoop}"
SWOOP_EXECUTION_DIR: "${SWOOP_EXECUTION_DIR:-s3://swoop/execution}"
SWOOP_EXECUTION_DIR: "${SWOOP_EXECUTION_DIR:-s3://swoop/executions}"
SWOOP_WORKFLOW_CONFIG_FILE: "${SWOOP_WORKFLOW_CONFIG_FILE:-workflow-config.yml}"
PGDATABASE: "${PGDATABASE:-swoop}"
PGHOST: "postgres"
Expand Down
5 changes: 5 additions & 0 deletions src/swoop/api/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@ def from_action_record(
class JobList(BaseModel):
jobs: list[StatusInfo]
links: list[Link]


class WorkflowExecutionInput(BaseModel):
inputs: dict
links: list[Link]
15 changes: 12 additions & 3 deletions src/swoop/api/routers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
StatusCode,
StatusInfo,
SwoopStatusCode,
WorkflowExecutionInput,
status_dict,
)
from swoop.api.models.shared import APIException, Link, Results
Expand Down Expand Up @@ -287,7 +288,7 @@ async def get_workflow_execution_result(
"""
Retrieves workflow execution output payload by jobID
"""
results = request.app.state.io.get_object(f"/execution/{jobID}/output.json")
results = request.app.state.io.get_object(f"/executions/{jobID}/output.json")

if not results:
raise HTTPException(
Expand All @@ -309,14 +310,22 @@ async def get_workflow_execution_inputs(request: Request, jobID) -> dict | APIEx
"""
Retrieves workflow execution input payload by jobID
"""
payload = request.app.state.io.get_object(f"/execution/{jobID}/input.json")
payload = request.app.state.io.get_object(f"/executions/{jobID}/input.json")

if not payload:
raise HTTPException(
status_code=404, detail="Workflow execution input payload not found"
)

return payload
links = [
Link.root_link(request),
Link.self_link(href=str(request.url)),
]

return WorkflowExecutionInput(
inputs={"payload": payload},
links=links,
)


# @router.post(
Expand Down
22 changes: 17 additions & 5 deletions tests/api/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
[
{
"source": "base_01",
"destination": "/execution/0187c88d-a9e0-788c-adcb-c0b951f8be91",
"destination": "/executions/0187c88d-a9e0-788c-adcb-c0b951f8be91",
},
{
"source": "base_02",
"destination": "/execution/0187c88d-a9e0-757e-aa36-2fbb6c834cb5",
"destination": "/executions/0187c88d-a9e0-757e-aa36-2fbb6c834cb5",
},
],
__name__,
Expand Down Expand Up @@ -441,10 +441,22 @@ async def test_get_job_payload(test_client: TestClient):
"/jobs/0187c88d-a9e0-788c-adcb-c0b951f8be91/inputs",
)
assert response.status_code == 200
print(response.json())

assert response.json() == {
"process_id": "0187c88d-a9e0-788c-adcb-c0b951f8be91",
"payload": "test_input",
"inputs": {
"payload": {
"process_id": "0187c88d-a9e0-788c-adcb-c0b951f8be91",
"payload": "test_input",
}
},
"links": [
{"href": "http://testserver/", "rel": "root", "type": "application/json"},
{
"href": "http://testserver/jobs/0187c88d-a9e0-788c-adcb-c0b951f8be91/inputs",
"rel": "self",
"type": "application/json",
},
],
}


Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ def inject_io_fixture(io_fixtures, io_postfix=None, scope="module"):
[
{
"source": "base_01",
"destination": "/execution/2595f2da-81a6-423c-84db-935e6791046e",
"destination": "/executions/2595f2da-81a6-423c-84db-935e6791046e",
},
{
"source": "base_02",
"destination": "/execution/81842304-0aa9-4609-89f0-1c86819b0752",
"destination": "/executions/81842304-0aa9-4609-89f0-1c86819b0752",
},
],
__name__,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
[
{
"source": "base_01",
"destination": "/execution/2595f2da-81a6-423c-84db-935e6791046e",
"destination": "/executions/2595f2da-81a6-423c-84db-935e6791046e",
},
{
"source": "base_02",
"destination": "/execution/81842304-0aa9-4609-89f0-1c86819b0752",
"destination": "/executions/81842304-0aa9-4609-89f0-1c86819b0752",
},
],
__name__,
Expand All @@ -30,14 +30,14 @@ def test_hasbucket(test_client, bucket_name):

def test_add_object(test_client, single_object):
test_client.app.state.io.put_object(
"/execution/2595f2da-81a6-423c-84db-935e6791046e/io.json",
"/executions/2595f2da-81a6-423c-84db-935e6791046e/io.json",
json.dumps(single_object),
)
assert True


def test_remove_object(test_client):
test_client.app.state.io.delete_object(
"/execution/2595f2da-81a6-423c-84db-935e6791046e/io.json"
"/executions/2595f2da-81a6-423c-84db-935e6791046e/io.json"
)
assert True