Pipeline API

Prerequisites

  • Token with Pipeline scope

  • The Pipeline ID to pass to the API call

You can find the Pipelines ID on the metadata page

Run Pipeline

POST https://{domain}/api/v1/computations

This API allows for the running of capsules or pipelines.

Path Parameters

NameTypeDescription

POST*

/computations/

Headers

NameTypeDescription

-u*

Authorize with Code Ocean API Secret:

-u $API_SECRET :

This is setting the "Authorization Basic" base64string header

-H

Set this to: Content - Type: application/json

--data-raw

JSON data with new or updated permissions

Request Body

NameTypeDescription

capsule_id

string

the identification of the capsule

Response Description
  • created - string

    • the data asset creation time in seconds from unix epoch

  • has_results - boolean

    • if any results are available

  • id - string

    • the computation internal id

  • name - array

    • name of the run

  • run_time - integer

    • unknown

  • state - initializing

    • unknown

Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/computations' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\' \
--data-raw '{
"pipeline_id": "4bc97533-6eb4-48ac-966f-648548a756d2"
}'
Request Example Python
import os, requests 


headers = {
  "Content-Type": "application/json"
}


json_data = {
  "pipeline_id": "4bc97533-6eb4-48ac-966f-648548a756d2"
} 


response = requests.put('https://codeocean.com/api/v1/data_assets/d36665a7-ef59-4b8e-a799-bee7f83ee317', 
headers=headers, json=json_data, auth=("'" + os.getenv('API_SECRET', ''), "'"), 
)
Response
{
  "created": 1689689613,
  "has_results": false,
  "id": "9af23fd6-2957-40bf-b691-16190056c94e",
  "name": "Run 9689613",
  "run_time": 0,
  "state": "initializing"
}

Run Pipeline with Data Assets

POST https://{domain}/api/v1/computations

This API allows for running of capsules or pipelines.

Path Parameters

NameTypeDescription

POST*

/computations/

Your VPC domain

Headers

NameTypeDescription

-u*

Authorize with Code Ocean API Secret: -u $API_SECRET :

This is setting the "Authorization Basic" base64string header

-H*

Set this to: Content - Type: application/json

--data-raw*

JSON data with new or updated permissions

Request Body

NameTypeDescription

capsule_id*

string

the identification of the data asset to be used in computational run the id of the capsule/pipeline to run

data_assets*

string

id*

string

the identification of the data asset to be used in computational run

mount*

string

the name of the folder you wish to mount this dataset into position

{
  "id": string - the computation internal id,
  "created": float64 - computation creation time,
  "name": string - the display name of the computation,
  "run_time": int - the total run time in seconds,

  "parameters": [
    {
      "name": string parameter name,
      "value": string parameter value
    },
    {
      "name": string parameter name,
      "value": string parameter value
    }
  ],
  "result_size": float64 - result size,
  "state": string - initializing,running,finalizing, completed
}
Request Example Bash
curl -H "Content-Type: application/json" -u ${API_SECRET}: -X POST https://codeocean.com/api/v1/computations --data-raw '{
"pipeline_id":"4bc97533-6eb4-48ac-966f-648548a756d2",
"data_assets": [
    {
        "id": "bf8cf993-a583-495c-bebd-2f38f81d1ea1", 
        "mount": "Alignment"
    }
]
Request Example Python
import os, requests 


headers = {
  "Content-Type": "application/json"
}
 
json_data = {
  "pipeline_id": "4bc97533-6eb4-48ac-966f-648548a756d2",
  "data_assets": [
      {
        "id": "bf8cf993-a583-495c-bebd-2f38f81d1ea1",
        "mount": "Alignment"
      }
  ]
}
 
response = requests.post('https://codeocean.com/api/v1/computations', headers=headers, 
json=json_data, 
auth=(os.getenv('API_SECRET', ''), ''), 
)
Response
{
  "created": 1689691505,
  "has_results": false,
  "id": "94994ace-cd3d-4e38-9c5c-9aed12a5169d",
  "name": "Run 9691505",
  "run_time": 1,
  "state": "initializing"
}

Run Pipeline with Data Assets & Parameters

POST https://{domain}/api/v1/computations

This API allows for the running of Capsules/Pipelines with Data Assets and Named parameters.

Prerequisite

Before using this API call, you should have AWS Cloud Credentials configured as Secrets or an Assumable Role.

Path Parameters

NameTypeDescription

POST*

/computations/

Headers

NameTypeDescription

-u:*

Authorize with Code Ocean API Secret: -u $API_SECRET :

-H:*

Set this to: Content - Type: application/json

--data-raw:

JSON data with capsule/pipeline information

Request Body

NameTypeDescription

capsule_id*

string

identification of the capsule if both capsule_id and pipeline_id are used, only the capsule id wll be used

pipeline_id

string

identification of the pipeline

data_assets*

array

ID*

string

identification of the data asset to be used in the computational run

Mount*

string

name of the folder to mount the dataset into position

processes

string

name*

string

pipeline process name as it appears in the main.nf script

parameters

string

parameters expected by the capsule

Ordered Parameters

Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/computations' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\' \
--data-raw '{
 "pipeline_id":"e7a77780-b8ae-439e-89ac-fac2549da91b",
 "data_assets" : [
       {
           "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712",
           "mount": "Reference"
       }
   ],
 "processes": [
       {
           "name": "capsule_art_simulation_illumina_1",
           "parameters": [
               "75","1","HS25","SingleEnded","","","1","","","","","","","False","False"
           ]      
       }
   ]
}'
Request Example Python
import os, requests

headers = {
 "Content-Type": "application/json"
}
json_data = {
 "pipeline_id":"e7a77780-b8ae-439e-89ac-fac2549da91b",
 "data_assets" : [
       {
           "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712",
           "mount": "Reference"
       }
   ],
 "processes": [
       {
           "name": "capsule_art_simulation_illumina_1",
           "parameters": [
               "75","1","HS25","SingleEnded","","","1","","","","","","","False","False"
           ]      
       }
   ]
}
response = requests.post('https://codeocean.com/api/v1/computations', headers=headers,
json=json_data,auth=(os.getenv('API_SECRET', ''), ''),)
Response
{
    "created":1701872878,
    "Data_assets":
    [
        {
            "Id":"eeefcc52-b445-4e3c-80c5-0e65526cd712",
            "mount":"Reference"
        }
    ],
    "Has_results":false,
    "Id":"3e4041e3-1970-4bc8-9d55-56887d4c5375",
    "name":"Run With Parameters 1872878",
    "Run_time":1,
    "state":"initializing"
}

Named Parameters

Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/computations' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\' \
--data-raw '{
 "pipeline_id":"4c4cd610-83bf-4a9b-9dfb-3faf6c29d11b",
 "data_assets": [
    {
        "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712", 
        "mount": "Reference"
    }
],
 "processes": [
       {
           "name": "capsule_np_create_folders_test_1",
           "named_parameters": [
               {
                   "param_name": "NumFiles",
                   "value": "10"
               }
           ]
       }
   ]
}'
Request Example Python
import os, requests

headers = {
 "Content-Type": "application/json"
}
json_data = {
 "pipeline_id":"4c4cd610-83bf-4a9b-9dfb-3faf6c29d11b",
 "data_assets": [
    {
        "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712", 
        "mount": "Reference"
    }
],
 "processes": [
       {
           "name": "capsule_np_create_folders_test_1",
           "named_parameters": [
               {
                   "param_name": "NumFiles",
                   "value": "10"
               }
           ]
       }
   ]
}
response = requests.post('https://codeocean.com/api/v1/computations', headers=headers,
json=json_data,auth=(os.getenv('API_SECRET', ''), ''),)
Response
{
    "created":1701872878,
    "Data_assets":
        [
            {
                "Id":"9c5cf74f-196b-4ed1-868c-8cf95c1f7182",
                "mount":"Reference"
            }
    ],
    "Has_results":false,
    "Id":"3e4041e3-1970-4bc8-9d55-56887d4c5375",
    "name":"Run With Parameters 1872878",
    "Run_time":1,
    "state":"initializing"
}

Ordered & Named Parameters

Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/computations' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\' \
--data-raw '{
 "pipeline_id":"cd4ef788-b404-4406-8bda-76b5e41a7b8d",
 "data_assets": [
        {
            "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712", 
            "mount": "Reference"
    }
],
 "processes": [
       {
           "name": "capsule_np_create_files_test_3",
           "named_parameters": [
               {
                   "param_name": "NumFiles",
                   "value": "10"
               }
           ]
       },
       {
           "name": "capsule_art_simulation_illumina_1",
           "parameters": [
               "75","1","HS25","SingleEnded","","","1","","","","","","","False","False"
           ]      
       }
   ]
}'
Request Example Python
import os, requests

headers = {
 "Content-Type": "application/json"
}

json_data = {
"pipeline_id":"cd4ef788-b404-4406-8bda-76b5e41a7b8d",
"data_assets" : [
       {
           "id": "eeefcc52-b445-4e3c-80c5-0e65526cd712",
           "mount": "Reference"
       }
   ],
 "processes": [
       {
           "name": "capsule_np_create_files_test_3",
           "named_parameters": [
               {
                   "param_name": "NumFiles",
                   "value": "10"
               }
           ]
       },
       {
           "name": "capsule_art_simulation_illumina_1",
           "parameters": [
           "75","1","HS25","SingleEnded","","","1","","","","","","","False","False"
           ]      
       }
   ]
}
response = requests.post('https://codeocean.com/api/v1/computations', headers=headers,
json=json_data,auth=(os.getenv('API_SECRET', ''), ''),)
Response
{
    "created":1701872878,
    "Data_assets":
    [
        {
            "Id":"eeefcc52-b445-4e3c-80c5-0e65526cd712",
            "mount":"Reference"
        }
    ],
    "Has_results":false,
    "Id":"3e4041e3-1970-4bc8-9d55-56887d4c5375",
    "name":"Run With Parameters 1872878",
    "Run_time":1,
    "state":"initializing"
}

Run Version of Pipeline

Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/computations' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\' \
--data-raw '{
"pipeline_id": "4bc97533-6eb4-48ac-966f-648548a756d2",
"version": 1
}'
Request Example Python
import os, requests 


headers = {
  "Content-Type": "application/json"
} 


json_data = {
  "pipeline_id": "4bc97533-6eb4-48ac-966f-648548a756d2",
  "version": 1
}
 
response = requests.post('https://codeocean.com/api/v1/computations', headers=headers, json=json_data, auth=("'" + os.getenv('API_SECRET', ''), "'"), 
)
Response
{
  "created": 1689689613,
  "has_results": false,
  "id": "9af23fd6-2957-40bf-b691-16190056c94e",
  "name": "Run 9689613",
  "run_time": 0,
  "state": "initializing"
}

Last updated