Skip to content

Commit

Permalink
CORE-1997 Replace /callbacks/agave-job with /callbacks/tapis-job
Browse files Browse the repository at this point in the history
  • Loading branch information
psarando committed Dec 19, 2024
1 parent aaa29cc commit 4a6c8f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[org.cyverse/metadata-client "3.1.2"]
[org.cyverse/common-cli "2.8.2"]
[org.cyverse/common-cfg "2.8.3"]
[org.cyverse/common-swagger-api "3.4.7"]
[org.cyverse/common-swagger-api "3.4.8"]
[org.cyverse/cyverse-groups-client "0.1.9"]
[org.cyverse/permissions-client "2.8.4"]
[org.cyverse/service-logging "2.8.4"]
Expand Down
13 changes: 6 additions & 7 deletions src/apps/routes/callbacks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:use [apps.routes.schemas.callback]
[common-swagger-api.schema]
[common-swagger-api.schema.analyses :only [AnalysisIdPathParam]]
[common-swagger-api.schema.callbacks :only [AgaveJobStatusUpdateParams AgaveJobStatusUpdate]]
[common-swagger-api.schema.callbacks :only [TapisJobStatusUpdate]]
[ring.util.http-response :only [ok]])
(:require [apps.service.callbacks :as callbacks]))

Expand All @@ -13,10 +13,9 @@
:description "The jex-events service calls this endpoint when the status of a DE analysis changes"
(ok (callbacks/update-de-job-status body)))

(POST "/agave-job/:job-id" []
(POST "/tapis-job/:job-id" []
:path-params [job-id :- AnalysisIdPathParam]
:body [body (describe AgaveJobStatusUpdate "The updated job status information.")]
:query [params AgaveJobStatusUpdateParams]
:summary "Update the status of an Agave analysis."
:description "The DE registers this endpoint as a callback when it submts jobs to Agave."
(ok (callbacks/update-tapis-job-status job-id (:lastUpdated body) params))))
:body [body (describe TapisJobStatusUpdate "The updated job status information.")]
:summary "Update the status of an Tapis analysis."
:description "The DE registers this endpoint as a callback when it submts jobs to Tapis."
(ok (callbacks/update-tapis-job-status job-id body))))
3 changes: 1 addition & 2 deletions src/apps/service/apps/tapis/jobs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

(defn- build-callback-url
[id]
(str (assoc (curl/url (config/tapis-callback-base) (str id))
:query "status=${JOB_STATUS}&external-id=${JOB_ID}&end-time=${JOB_END_TIME}")))
(str (curl/url (config/tapis-callback-base) (str id))))

(defn- format-submission
[_ job-id result-folder-path {:keys [config] :as submission}]
Expand Down
13 changes: 8 additions & 5 deletions src/apps/service/callbacks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
(apps/update-job-status uuid))

(defn update-tapis-job-status
[job-id last-updated {:keys [status external-id end-time]}]
[job-id {{:keys [timestamp type data]} :event}]
(service/assert-valid job-id "no job UUID provided")
(service/assert-valid status "no status provided")
(service/assert-valid external-id "no external job ID provided")
(log/info (str "received a status update for Tapis job " external-id ": status = " status))
(apps/update-job-status job-id external-id status (first (remove string/blank? [end-time last-updated]))))
(service/assert-valid type "no status provided")
(let [{:keys [jobUuid]} (service/parse-json data)
; The `event.type` will be a string like "jobs.JOB_NEW_STATUS.FINISHED"
status (string/replace type #".*\." "")]
(service/assert-valid jobUuid "no external job ID provided")
(log/info (str "received a status update for Tapis job " jobUuid ": type = " type ", status = " status))
(apps/update-job-status job-id jobUuid status timestamp)))

0 comments on commit 4a6c8f2

Please sign in to comment.