github.com/DataBiosphere/terra-scientific-pipelines-service/LiftoverVcfs
Authors: Terra Scientific Services
Type: Software
Published: 2026-08-03

<h1>Terra Scientific Pipelines Service</h1>
<p><a href="https://sonarcloud.io/summary/new_code?id=DataBiosphere_terra-scientific-pipelines-service"></a></p>
<h2>Overview</h2>
<p>Terra Scientific Pipelines Service, or Teaspoons, facilitates running a number of defined scientific pipelines
on behalf of users that users can't run themselves in Terra. The most common reason for this is that the pipeline
accesses proprietary data that users are not allowed to access directly, but that may be used as e.g. a reference panel
for imputation.</p>
<h2>Supported pipelines</h2>
<p>Current supported pipelines are:</p>
<ul>
<li><a href="https://allofus-anvil-imputation.terra.bio/">Array Imputation with the <em>All of Us</em> + AnVIL Reference Panel</a></li>
</ul>
<h2>Architecture</h2>
<p><a href="https://docs.google.com/document/d/1dAPwOG2z1h0B5CszeQ0DfyToniNV_3y1OBV7x7L8ofI/edit?usp=sharing">Architecture Doc</a></p>
<p><a href="https://lucid.app/lucidchart/2f067b5e-2d40-41b4-a5f3-a9dc72d83820/edit?viewport_loc=-72%2C25%2C1933%2C1133%2C0_0&invitationId=inv_97522cca-1b6d-44fe-9552-8f959d410dd7">Architecture Diagram</a></p>
<h2>Development</h2>
<p>This codebase is in initial development.</p>
<h3>Requirements</h3>
<h4>Technical</h4>
<p>This service is written in Java 17, and uses Postgres 15.</p>
<p>To run locally, you'll also need:</p>
<ul>
<li>jq - install with <code>brew install jq</code></li>
<li>Java 17 - can be installed manually or through IntelliJ which will do it for you when importing the project</li>
<li>Postgres 15 - multiple solutions here as long as you have a postgres instance running on localhost:5432 the local app will connect appropriately. Be sure to use Postgres 15 (as of Feb 2025, Postgres 17 did not work)
<ul>
<li>Download Postgres.app (recommended) from https://postgresapp.com/</li>
<li>Brew https://formulae.brew.sh/formula/postgresql@15</li>
</ul>
</li>
</ul>
<h4>External Services</h4>
<p>Terra services</p>
<ul>
<li>Sam
<ul>
<li>Used to authn users connecting to the service and authz users for admin endpoints</li>
</ul>
</li>
<li>Rawls
<ul>
<li>Used to handle workspace interactions
<ul>
<li>creating methods</li>
<li>data tables</li>
<li>workflow submission</li>
</ul>
</li>
</ul>
</li>
<li>Cromwell
<ul>
<li>Used through Rawls to run submissions</li>
</ul>
</li>
<li>Thurloe
<ul>
<li>Used to send notification emails to users</li>
</ul>
</li>
</ul>
<h3>Tech stack</h3>
<ul>
<li>Java 17 temurin</li>
<li>Postgres 15</li>
<li>Gradle - build automation tool</li>
<li>SonarQube - static code security and coverage</li>
<li>Trivy - security scanner for docker images</li>
<li>Jib - docker image builder for Java</li>
</ul>
<h3>Local development</h3>
<p>To run locally:</p>
<ol>
<li>Make sure you have the requirements installed from above. We recommend IntelliJ as an IDE.</li>
<li>Clone the repo (if you see broken inputs build the project to get the generated sources)</li>
<li>Spin up a local postgres instance (NOTE: use version 15)</li>
<li>Run the commands in <code>scripts/postgres-init.sql</code> in your local postgres instance. You will need to be authenticated to access GSM.</li>
<li>Run <code>scripts/write-config.sh</code></li>
<li>Run <code>./gradlew bootRun</code> to spin up the server.</li>
<li>Navigate to <a href="http://localhost:8080/#">http://localhost:8080/#</a></li>
<li>If this is your first time deploying to any environment, be sure to use the admin endpoint <code>/api/admin/v1/pipelines/{pipelineName}/{pipelineVersion}</code> to set your pipeline's workspace id.
<ol>
<li>To run this endpoint, you need to be authenticated using your firecloud test account. A list of accounts that developers typically need is <a href="https://broadworkbench.atlassian.net/wiki/spaces/TSPS/pages/3699605509/Accounts+for+developers">here</a>. Further, a list of resources that are generally useful is stored <a href="https://broadworkbench.atlassian.net/wiki/spaces/TSPS/pages/2887778308/Teaspoons+Resources">here</a></li>
<li>This endpoint requires two parameters directly, and three in the message body:
<ol>
<li>pipelineName can be retrieved by querying the <code>/api/pipelines/v1</code> endpoint.</li>
<li>pipelineVersion can also be retrieved from the <code>/api/pipelines/v1</code> endpoint.</li>
<li>workspaceBillingProject is listed in the Teaspoons Resources document linked above</li>
<li>workspaceName is also listed in the Teaspoons Resources document, and can be found through the Terra UI workspace dashboard</li>
<li>wdlMethodVersion is found for the specific workflow as listed in the Terra UI page for workflows.</li>
</ol>
</li>
</ol>
</li>
</ol>
<h4>Back up local Postgres databases before testing/refactors</h4>
<p>Before running local migrations/refactors, take backups of both local databases so you can restore quickly.</p>
<p>Defaults in this repo (see <code>service/src/main/resources/application.yml</code> and <code>scripts/postgres-init.sql</code>):</p>
<ul>
<li>host <code>127.0.0.1</code>, port <code>5432</code></li>
<li><code>pipelines_db</code> user/pass: <code>dbuser</code> / <code>dbpwd</code></li>
<li><code>teaspoons_stairway_db</code> user/pass: <code>stairwayuser</code> / <code>stairwaypwd</code></li>
</ul>
<p>Backup and verify:</p>
<pre><code class="language-zsh">ts="$(date +%Y%m%d_%H%M%S)"
backup_dir="$HOME/teaspoons-db-backups/$ts"
mkdir -p "$backup_dir"

PGHOST=127.0.0.1 PGPORT=5432 PGUSER=dbuser PGPASSWORD=dbpwd \
pg_dump -Fc -f "$backup_dir/pipelines_db.dump" pipelines_db

PGHOST=127.0.0.1 PGPORT=5432 PGUSER=stairwayuser PGPASSWORD=stairwaypwd \
pg_dump -Fc -f "$backup_dir/teaspoons_stairway_db.dump" teaspoons_stairway_db

pg_restore -l "$backup_dir/pipelines_db.dump" | head
pg_restore -l "$backup_dir/teaspoons_stairway_db.dump" | head

echo "Backups written to: $backup_dir"
</code></pre>
<p>Restore later (replace <code><admin_password></code>):</p>
<pre><code class="language-zsh">PGHOST=127.0.0.1 PGPORT=5432 PGUSER=postgres PGPASSWORD=<admin_password> dropdb --if-exists pipelines_db
PGHOST=127.0.0.1 PGPORT=5432 PGUSER=postgres PGPASSWORD=<admin_password> createdb -O dbuser pipelines_db
PGHOST=127.0.0.1 PGPORT=5432 PGUSER=dbuser PGPASSWORD=dbpwd \
pg_restore --clean --if-exists --no-owner -d pipelines_db "$backup_dir/pipelines_db.dump"

PGHOST=127.0.0.1 PGPORT=5432 PGUSER=postgres PGPASSWORD=<admin_password> dropdb --if-exists teaspoons_stairway_db
PGHOST=127.0.0.1 PGPORT=5432 PGUSER=postgres PGPASSWORD=<admin_password> createdb -O stairwayuser teaspoons_stairway_db
PGHOST=127.0.0.1 PGPORT=5432 PGUSER=stairwayuser PGPASSWORD=stairwaypwd \
pg_restore --clean --if-exists --no-owner -d teaspoons_stairway_db "$backup_dir/teaspoons_stairway_db.dump"
</code></pre>
<h3>Local development with the UI</h3>
<p>When running terra-ui locally against a local teaspoons backend, CORS-related errors can arise. To get around this, run the following command to copy a configuration file that allows requests from localhost:</p>
<pre><code class="language-bash">./scripts/local-dev/copy_web_config.sh 
</code></pre>
<p>Note that this file at the destination path (next to App.java) is ignored via .gitignore, since it should not be used in deployed environments.</p>
<h4>Local development with debugging</h4>
<p>If using Intellij (only IDE we use on the team), you can run the server with a debugger. Follow
the steps above but instead of running <code>./gradlew bootRun</code> to spin up the server, you can run
(debug) the App.java class through intellij and set breakpoints in the code.  Be sure to set the
GOOGLE_APPLICATION_CREDENTIALS=config/teaspoons-sa.json in the Run/Debug configuration Environment Variables.</p>
<h3>Testing the CLI locally</h3>
<p>If you make changes to <a href="common/openapi.yml">openapi.yml</a>, you should test the CLI locally.</p>
<p>To create the autogenerated Python client files locally, run</p>
<pre><code class="language-bash">./gradlew :python-client:openApiGenerate
</code></pre>
<p>The files will be generated in <code>python-client/generated</code> and are ignored from being checked into the repo.
(Note: the unqualified <code>./gradlew openApiGenerate</code> now regenerates all four codegen modules —
<code>python-client</code>, <code>rawls-client</code>, <code>client</code>, and <code>service</code> — so qualify the task when you only want the Python client.)</p>
<p>To test with the CLI, follow the instructions in the CLI repo: <a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service-cli/blob/main/CONTRIBUTING.md">DataBiosphere/terra-scientific-pipelines-service-cli</a>.</p>
<h3>Running Tests Locally</h3>
<p>Run <code>./gradlew service:test</code> to run tests</p>
<p>Note: If you encounter errors indicating a failure to load the ApplicationContext due to an error while preparing a database cluster caused by a missing Docker environment,
this may be related to newer Docker versions (for example, 29.0.0 and above). To resolve this issue, override the
Docker API version in the <code>$HOME/.docker-java.properties</code> file. If the file does not already exist, create it and add the following line:</p>
<pre><code>api.version=1.44
</code></pre>
<p>If the file mentioned already exists with above line, and the tests are still failing in the same way, try restarting Docker.</p>
<h3>Running Linter Locally</h3>
<ul>
<li>Run <code>./gradlew spotlessCheck</code> to run linter checks</li>
<li>Run <code>./gradlew :service:spotlessApply</code> to apply fix any issues the linter finds</li>
</ul>
<h3>(Optional) Install pre-commit hooks</h3>
<ol>
<li>[scripts/git-hooks/pre-commit] has been provided to help ensure all submitted changes are formatted correctly.  To install all hooks in [scripts/git-hooks], run:</li>
</ol>
<pre><code class="language-bash">git config core.hooksPath scripts/git-hooks
</code></pre>
<h3>Running SonarQube locally</h3>
<p><a href="https://www.sonarqube.org">SonarQube</a> is a static analysis code that scans code for a wide
range of issues, including maintainability and possible bugs. Get more information from
<a href="https://dsp-security.broadinstitute.org/appsec-team-internal/appsec-team-internal/security-activities/sast-1#">DSP SonarQube Docs</a></p>
<p>If you get a build failure due to
SonarQube and want to debug the problem locally, you need to get the sonar token from GSM
before running the gradle task.</p>
<pre><code class="language-shell">export SONAR_TOKEN=$(gcloud secrets versions access latest --project="broad-dsde-dev" --secret="teaspoons-sonarcloud" | jq '.sonar_token')
./gradlew sonarqube
</code></pre>
<p>Running this task produces no output unless your project has errors. To
generate a report, run using <code>--info</code>:</p>
<pre><code class="language-shell">./gradlew sonarqube --info
</code></pre>
<h3>Connecting to the database</h3>
<p>To connect to the Teaspoons database, we have a script in <a href="https://github.com/broadinstitute/dsp-scripts">dsp-scripts</a> that
does all the setup for you. Clone that repo and make sure you're either on Broad Internal wifi or connected
to the VPN. Then run the following command:</p>
<pre><code class="language-shell">./db/psql-connect.sh dev teaspoons
</code></pre>
<h3>Deploying to dev</h3>
<p>Upon merging to main, the dev environment will be automatically deployed via the GitHub Action <a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service/actions/workflows/tag-publish.yml">Bump, Tag, Publish, and Deploy</a>
(that workflow is defined <a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service/blob/main/.github/workflows/tag-publish.yml">here</a>).</p>
<p>The two tasks <code>report-to-sherlock</code> and <code>set-version-in-dev</code> will prompt Sherlock to deploy the new version to dev.
You can check the status of the deployment in <a href="https://beehive.dsp-devops.broadinstitute.org/apps/teaspoons">Beehive</a> and in
<a href="https://ap-argocd.dsp-devops.broadinstitute.org/applications/ap-argocd/teaspoons-dev">ArgoCD</a>.</p>
<p>For more information about deployment to dev, check out DevOps' <a href="https://docs.google.com/document/d/1lkUkN2KOpHKWufaqw_RIE7EN3vN4G2xMnYBU83gi8VA/">excellent documentation</a>.</p>
<h3>Tracing</h3>
<p>We use <a href="https://opentelemetry.io/">OpenTelemetry</a> for tracing, so that every request has a tracing span that can
be viewed in <a href="https://cloud.google.com/trace">Google Cloud Trace</a>.
See <a href="https://broadworkbench.atlassian.net/wiki/x/AoGlrg">this DSP blog post</a> for more info.</p>
<h3>Running the BEE end-to-end tests</h3>
<p>The end-to-end test that runs against a BEE is specified in <code>.github/workflows/run-bee-e2e-tests.yaml</code>. It calls <a href="https://github.com/broadinstitute/terra-github-workflows/blob/main/.github/workflows/teaspoons-bee-e2e-service-test.yaml">the workflow defined
in the terra-github-workflows repo</a>.</p>
<p>The end-to-end test is automatically run nightly on the dev environment.</p>
<p>To run the test against a specific feature branch:</p>
<ol>
<li>Grab the image tag for your feature branch.</li>
</ol>
<blockquote>
<p>If you've opened a PR, you can find the image tag as follows:</p>
<ul>
<li>go to the Bump, Tag, Publish, and Deploy workflow that's triggered each time you push to your branch</li>
<li>From there, go to the tag-publish-docker-deploy task</li>
<li>Expand the "Construct docker image name and tag" step</li>
<li>The first line should contain the image tag, something like "0.0.81-6761487".</li>
</ul>
</blockquote>
<ol>
<li>Navigate to the <a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service/actions/workflows/run-bee-e2e-tests.yaml">e2e-test GHA workflow</a></li>
<li>Click on the "Run workflow" button and select your branch from the dropdown</li>
</ol>
<ul>
<li>Enter the image tag from step 1 in the "Custom image tag" field</li>
<li>If you've updated the end-to-end test in the dsp-resuable-workflows repo, enter either a commit hash or your git
branch name. If you don't need to change the test, leave the default as main.</li>
</ul>
<ol>
<li>Click the green "Run workflow" button.</li>
</ol>
<h2>Python clients</h2>
<p>We publish a "thin", auto-generated Python client that wraps the Teaspoons APIs. This client is published to
<a href="https://pypi.org/project/terra-scientific-pipelines-service-api-client/">PyPi</a> and can be installed with
<code>pip install teaspoons_client</code>, although this is not meant to be user-facing. The thin api client is generated from
the OpenAPI spec in the <code>openapi</code> directory.</p>
<p>Publishing occurs automatically when a new version of the service is deployed, via the
<a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service/blob/main/.github/workflows/release-python-client.yml">release-python-client GHA</a>.</p>
<p>We also have a user-facing, "thick" CLI whose code lives in a separate repository: <a href="https://github.com/DataBiosphere/terra-scientific-pipelines-service-cli">DataBiosphere/terra-scientific-pipelines-service-cli</a>.</p>