Skip to content
Snippets Groups Projects
Commit 142bb190 authored by Charlotte Hausman's avatar Charlotte Hausman Committed by Daniel Lyons
Browse files

WS-474: REST calls and CLI for calibration ingestion

parent 6bef093a
No related branches found
No related tags found
1 merge request!329WS-474: REST calls and CLI for calibration ingestion
Pipeline #2156 passed
#!/usr/bin/env bash
set -o errexit -o nounset
function usage {
echo "Usage: ingest-request [-c] [workflow_request_id]
This script sets off a Workspaces ingestion workflow of the specified type,
given by the chosen option, for the provided workflow request id.
Options:
-c, --calibration run the ingest_cal workflow for the specified request
-h, --help display this help and exit
"
}
option=$(echo "$1" | tr A-Z a-z)
case $option in
--calibration|-c)
action="ingest_cal"
;;
--help|-h)
usage
;;
esac
WORKFLOW_SERVICE=$(capo -q edu.nrao.archive.workspaces.WorkflowSettings.serviceUrl)
if [ "$action" = "ingest_cal" ]; then
curl -X POST $WORKFLOW_SERVICE/workflows/std_calibration/requests/$2/ingest
fi
......@@ -238,6 +238,29 @@ class WorkflowRequestRestService:
return self.request.workflows.announce_qa_ready(self.request.matchdict["request_id"])
@view_config(request_method="POST", route_name="ingest_workflow_result")
def ingest(self):
"""
Ingest specified workflow request's results into NGAS and archive
:return:
"""
print(f"Ingesting results for workflow request {self.request.context}")
# 1. retrieve metadata.json for workflow request
self.request.matchdict["filename"] = "metadata.json"
file = lookup_file(request=self.request)
# 2. create ingestion workflow request
ingest_type = "ingest_cal" if "calibration" in self.request.matchdict["name"] else "ingest"
ingest_request = self.request.info.create_workflow_request(ingest_type)
# 3. attach metadata.json to ingestion wf request
self.request.workflows.attach_file_to_request(
request=ingest_request, filename=file.filename, content=file.content
)
# 4. submit ingestion workflow request
self.request.workflows.execute(ingest_request)
@view_defaults(route_name="workflow_request_files", renderer="json")
class WorkflowFilesRestService:
"""
......@@ -417,12 +440,15 @@ def main(global_config, **settings):
"/workflows/{name}/requests/{request_id}/submit",
factory=lookup_request,
)
config.add_route(
"ingest_workflow_result",
"/workflows/{name}/requests/{request_id}/ingest",
factory=lookup_request,
)
# yes I know this doesn't match pattern, it's a stopgap.
config.add_route(
"announce_qa_ready",
"/workflows/requests/{request_id}/qa",
factory=lookup_request
"announce_qa_ready", "/workflows/requests/{request_id}/qa", factory=lookup_request
)
config.include("pyramid_beaker")
config.scan(".")
......
......@@ -98,12 +98,21 @@ class WorkflowServiceRESTClient(WorkflowServiceIF):
Announce results are available for QA
THIS IS A WORKAROUND PENDING THE IMPLEMENTATION OF THE QA SYSTEM!
<insert unhappy tears here>
:param workflow_request: completed workflow request
:param workflow_request_id: id of completed workflow
:return:
"""
requests.post(f"{self.url}/workflows/requests/{workflow_request_id}/qa")
def ingest(self, request: WorkflowRequestIF):
"""
Ingest results for previously run workflow into NGAS and archive
:param request: completed workflow request to ingest
:return:
"""
requests.post(
f"{self.url}/workflows/{request.workflow_name}/requests/{request.workflow_request_id}/ingest"
)
class WorkflowService(WorkflowServiceIF):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment