-
Notifications
You must be signed in to change notification settings - Fork 0
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
[GH-1035] Add terra module to WFL #197
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(ns wfl.service.terra | ||
"Analyze data in Terra using the Firecloud/Terra API." | ||
(:require [clojure.data.json :as json] | ||
[clojure.string :as str] | ||
[clj-http.client :as http] | ||
[wfl.once :as once] | ||
[wfl.util :as util])) | ||
|
||
(defn workspace-api-url | ||
[terra-url workspace-namespace workspace-name] | ||
(str terra-url "/api/workspaces/" workspace-namespace "/" workspace-name)) | ||
|
||
(defn create-submission | ||
"Submit samples in a workspace for analysis with a method configuration in Terra." | ||
[terra-url workspace-namespace workspace-name method-configuration-name | ||
method-configuration-namespace entity-type entity-name] | ||
(let [workspace-url (workspace-api-url terra-url workspace-namespace workspace-name) | ||
submission-url (str workspace-url "/submissions")] | ||
(-> | ||
(http/post | ||
submission-url | ||
{:content-type :application/json | ||
:headers (once/get-auth-header) | ||
:body (json/write-str | ||
{ | ||
:methodConfigurationNamespace method-configuration-namespace | ||
:methodConfigurationName method-configuration-name | ||
:entityType entity-type | ||
:entityName entity-name | ||
:useCallCache true | ||
} :escape-slash false)}) | ||
:body | ||
(util/parse-json) | ||
:submissionId))) | ||
|
||
(defn get-submission | ||
"Get information about a Terra Cromwell submission." | ||
[terra-url workspace-namespace workspace-name submission-id] | ||
(let [workspace-url (workspace-api-url terra-url workspace-namespace workspace-name) | ||
submission-url (str workspace-url "/submissions/" submission-id) | ||
response (http/get submission-url {:headers (once/get-auth-header)})] | ||
(util/parse-json (:body response)))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(ns wfl.integration.terra-test | ||
(:require [clojure.test :refer [deftest is testing]] | ||
[wfl.service.terra :as terra] | ||
[wfl.tools.fixtures :refer [with-temporary-gcs-folder]])) | ||
|
||
(def terra-url | ||
"https://firecloud-orchestration.dsde-dev.broadinstitute.org") | ||
|
||
(def workspace-namespace | ||
"general-dev-billing-account") | ||
|
||
(def workspace-name | ||
"wfl-integration") | ||
|
||
(def method-configuration-name | ||
"ExternalWholeGenomeReprocessing") | ||
|
||
(def method-configuration-namespace | ||
"general-dev-billing-account") | ||
|
||
(def entity-type | ||
"sample") | ||
|
||
(def entity-name | ||
"NA12878_PLUMBING") | ||
|
||
(deftest test-terra-submission | ||
(testing "A workflow is created for the entity" | ||
(let [submission-id (terra/create-submission terra-url workspace-namespace workspace-name | ||
method-configuration-name method-configuration-namespace | ||
entity-type entity-name) | ||
submission (terra/get-submission terra-url workspace-namespace workspace-name submission-id) | ||
workflow (first (:workflows submission))] | ||
(is (= entity-name (get-in workflow [:workflowEntity :entityName])))))) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test. Makes it easier to see how it's meant to be used.
What's the difference between the namespace and the name? Does it make sense to combine these into a fully-qualified name? Thinking this would simplify the call site for both the workspace and the method configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
workspace-namespace
corresponds to a gcloud billing project and can contain multiple workspaces. Here's one I set up in dev using the "general-dev-billing-account" namespace: https://bvdp-saturn-dev.appspot.com/#workspaces. I like the idea of combining the two parameters into one since they're just used in the submission url.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it seems like the
method-configuration-namespace
will always be the same as theworkspace-namespace
. But they can be specified individually through the Terra API so I'm assuming there's a case where they can be different.