Skip to content

Commit 10382d8

Browse files
authored
Merge pull request #36 from unity-sds/mcduffie
Add notebook for interacting with Dockstore API to publish an application
2 parents 2fce4b8 + c126578 commit 10382d8

File tree

1 file changed

+255
-0
lines changed

1 file changed

+255
-0
lines changed
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "702d6a78-9eef-418a-b624-43ee8ee98643",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import os\n",
11+
"import sys"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 2,
17+
"id": "6f3a0abe-3a42-455d-b365-0f0039455570",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"sys.path.append(os.path.expanduser(\"~/unity-py\"))"
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": 3,
27+
"id": "0d63d3d2-0f6e-4303-b37d-8394e0e1411c",
28+
"metadata": {},
29+
"outputs": [],
30+
"source": [
31+
"from unity_py.services.application_service import *"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"id": "42bfa738-fc42-421a-b2cf-44b1204e32eb",
37+
"metadata": {},
38+
"source": [
39+
"## Configuration"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"id": "11b285a3-2b97-4cd1-9115-05beb47de12a",
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"dockstore_api_uri = \"http://uads-test-dockstore-deploy-lb-1762603872.us-west-2.elb.amazonaws.com:9998/api\""
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 5,
55+
"id": "2f1108d3-b0cb-49ec-9c87-d86515b102f9",
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"token = !cat ~/.dockstore/config | grep token | awk '{print $2}'\n",
60+
"token = token[0]"
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"id": "7e128d17-f0a4-4698-8ab1-4d68f0da0316",
66+
"metadata": {},
67+
"source": [
68+
"## Catalog Interface\n"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 6,
74+
"id": "b9dae047-4ac0-478c-87b7-b8011d09465c",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"app_catalog = DockstoreAppCatalog(dockstore_api_uri, token)"
79+
]
80+
},
81+
{
82+
"cell_type": "markdown",
83+
"id": "919b88c1-4e85-446e-801e-0ee76d264525",
84+
"metadata": {},
85+
"source": [
86+
"## Existing User Applications"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 7,
92+
"id": "4ca327d3-35fe-4455-8eae-a9d56a88c423",
93+
"metadata": {
94+
"tags": []
95+
},
96+
"outputs": [],
97+
"source": [
98+
"for app in app_catalog.application_list(for_user=True):\n",
99+
" print(f\"{app.id} {app.name} {app.source_repository}\")"
100+
]
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"id": "29b1516d-e67e-48d7-a2fc-e4293317f46a",
105+
"metadata": {},
106+
"source": [
107+
"## New Application"
108+
]
109+
},
110+
{
111+
"cell_type": "code",
112+
"execution_count": 8,
113+
"id": "fcbe7a9c-6893-424d-822a-f1c1a1b10773",
114+
"metadata": {},
115+
"outputs": [],
116+
"source": [
117+
"name = \"sounder_sips_l1a\"\n",
118+
"source_repository = \"[email protected]:unity-sds/sounder-sips-application.git\"\n",
119+
"workflow_path = \"/cwl/l1a_workflow.cwl\""
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 9,
125+
"id": "f2a48297-ca47-43b6-929e-484159876607",
126+
"metadata": {},
127+
"outputs": [],
128+
"source": [
129+
"new_app = ApplicationPackage(name, source_repository, workflow_path)"
130+
]
131+
},
132+
{
133+
"cell_type": "code",
134+
"execution_count": 10,
135+
"id": "eed8a991-dadb-48e9-91b2-fb93abfbf1f8",
136+
"metadata": {},
137+
"outputs": [
138+
{
139+
"data": {
140+
"text/plain": [
141+
"ApplicationPackage(name='sounder_sips_l1a', source_repository='[email protected]:unity-sds/sounder-sips-application.git', workflow_path='/cwl/l1a_workflow.cwl', id=None, is_published=False, description='', workflow_type='CWL')"
142+
]
143+
},
144+
"execution_count": 10,
145+
"metadata": {},
146+
"output_type": "execute_result"
147+
}
148+
],
149+
"source": [
150+
"new_app"
151+
]
152+
},
153+
{
154+
"cell_type": "markdown",
155+
"id": "1f94da3e-727a-456e-ab13-32edf688ddba",
156+
"metadata": {},
157+
"source": [
158+
"## Publish Application"
159+
]
160+
},
161+
{
162+
"cell_type": "code",
163+
"execution_count": 11,
164+
"id": "f3ea1bb2-00ff-46d6-9a18-ef23a5bd93f0",
165+
"metadata": {},
166+
"outputs": [],
167+
"source": [
168+
"reg_app = app_catalog.register(new_app)"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": 12,
174+
"id": "360a929a-bbbf-4a51-8433-b72f7424f7b7",
175+
"metadata": {},
176+
"outputs": [
177+
{
178+
"data": {
179+
"text/plain": [
180+
"DockstoreApplicationPackage(name='sounder_sips_l1a', source_repository='[email protected]:unity-sds/sounder-sips-application.git', workflow_path='/cwl/l1a_workflow.cwl', id='50', is_published=False, description='Processes Sounder SIPS L0 products into L1A products', workflow_type='CWL', dockstore_info={'type': 'BioWorkflow', 'descriptorType': 'CWL', 'aliases': {}, 'author': 'James McDuffie', 'checker_id': None, 'conceptDoi': None, 'dbCreateDate': 1670623272833, 'dbUpdateDate': 1670623276387, 'defaultTestParameterFilePath': '/test.json', 'defaultVersion': 'main', 'description': 'Processes Sounder SIPS L0 products into L1A products', 'descriptorTypeSubclass': 'NOT_APPLICABLE', 'email': '[email protected]', 'forumUrl': None, 'full_workflow_path': 'github.com/unity-sds/sounder-sips-application/sounder_sips_l1a', 'gitUrl': '[email protected]:unity-sds/sounder-sips-application.git', 'has_checker': False, 'id': 50, 'input_file_formats': [], 'isChecker': False, 'is_published': False, 'labels': [], 'lastUpdated': 1670623272828, 'last_modified': 2004663152, 'last_modified_date': 1668451974000, 'licenseInformation': {'licenseName': 'Other'}, 'mode': 'FULL', 'organization': 'unity-sds', 'output_file_formats': [], 'parent_id': None, 'path': 'github.com/unity-sds/sounder-sips-application', 'repository': 'sounder-sips-application', 'sourceControl': 'github.com', 'source_control_provider': 'GITHUB', 'starredUsers': [], 'topic': 'This repository represents the containerization of the Sounder SIPS SPSS repository into a Unity Application Package.', 'topicAutomatic': 'This repository represents the containerization of the Sounder SIPS SPSS repository into a Unity Application Package.', 'topicId': None, 'topicManual': None, 'topicSelection': 'AUTOMATIC', 'userIdToOrcidPutCode': None, 'users': [{'avatarUrl': 'https://avatars.githubusercontent.com/u/3554574?v=4', 'curator': False, 'id': 2, 'isAdmin': False, 'name': 'mcduffie', 'orcid': None, 'privacyPolicyVersion': 'PRIVACY_POLICY_VERSION_2_5', 'privacyPolicyVersionAcceptanceDate': 1660239673886, 'setupComplete': False, 'tosacceptanceDate': 1660239673886, 'tosversion': 'TOS_VERSION_2', 'userProfiles': None, 'username': 'mcduffie', 'usernameChangeRequired': False}], 'workflowName': 'sounder_sips_l1a', 'workflowVersions': [{'aliases': None, 'author': 'James McDuffie', 'authors': [{'affiliation': None, 'email': '[email protected]', 'name': 'James McDuffie', 'role': None}], 'commitID': 'a1e2cf4b07504820129cd8ed7554134b4534f79d', 'dbUpdateDate': 1670623276387, 'description': 'Processes Sounder SIPS L0 products into L1A products', 'descriptionSource': 'DESCRIPTOR', 'dirtyBit': False, 'doiStatus': 'NOT_REQUESTED', 'doiURL': None, 'email': '[email protected]', 'frozen': False, 'hidden': False, 'id': 73, 'images': None, 'input_file_formats': [], 'last_modified': 1668451974000, 'legacyVersion': True, 'name': 'main', 'orcidAuthors': None, 'output_file_formats': [], 'reference': 'main', 'referenceType': 'BRANCH', 'subClass': None, 'synced': True, 'valid': True, 'validations': None, 'verified': False, 'verifiedSource': None, 'verifiedSources': [], 'versionEditor': None, 'versionMetadata': {'description': 'Processes Sounder SIPS L0 products into L1A products', 'id': 73, 'parsedInformationSet': [{'descriptorLanguage': 'CWL', 'hasHTTPImports': False, 'hasLocalImports': True}], 'publicAccessibleTestParameterFile': None, 'userIdToOrcidPutCode': {}}, 'workflow_path': '/cwl/l1a_workflow.cwl', 'workingDirectory': 'cwl'}], 'workflow_path': '/cwl/l1a_workflow.cwl'})"
181+
]
182+
},
183+
"execution_count": 12,
184+
"metadata": {},
185+
"output_type": "execute_result"
186+
}
187+
],
188+
"source": [
189+
"reg_app"
190+
]
191+
},
192+
{
193+
"cell_type": "markdown",
194+
"id": "704a1308-796f-4591-adf1-a98b35a20b26",
195+
"metadata": {
196+
"tags": []
197+
},
198+
"source": [
199+
"## Delete Application (Cleanup)"
200+
]
201+
},
202+
{
203+
"cell_type": "code",
204+
"execution_count": 13,
205+
"id": "307ee2df-c596-4170-81bb-faff193c86b7",
206+
"metadata": {},
207+
"outputs": [],
208+
"source": [
209+
"del_app = app_catalog.unregister(reg_app, delete=True)"
210+
]
211+
},
212+
{
213+
"cell_type": "code",
214+
"execution_count": 14,
215+
"id": "f76c6475-ca8e-46be-bf1e-1608cd628f9d",
216+
"metadata": {},
217+
"outputs": [
218+
{
219+
"data": {
220+
"text/plain": [
221+
"DockstoreApplicationPackage(name='sounder_sips_l1a', source_repository='[email protected]:unity-sds/sounder-sips-application.git', workflow_path='/cwl/l1a_workflow.cwl', id=None, is_published=False, description='Processes Sounder SIPS L0 products into L1A products', workflow_type='CWL', dockstore_info=None)"
222+
]
223+
},
224+
"execution_count": 14,
225+
"metadata": {},
226+
"output_type": "execute_result"
227+
}
228+
],
229+
"source": [
230+
"del_app"
231+
]
232+
}
233+
],
234+
"metadata": {
235+
"kernelspec": {
236+
"display_name": "Python 3 (ipykernel)",
237+
"language": "python",
238+
"name": "python3"
239+
},
240+
"language_info": {
241+
"codemirror_mode": {
242+
"name": "ipython",
243+
"version": 3
244+
},
245+
"file_extension": ".py",
246+
"mimetype": "text/x-python",
247+
"name": "python",
248+
"nbconvert_exporter": "python",
249+
"pygments_lexer": "ipython3",
250+
"version": "3.10.6"
251+
}
252+
},
253+
"nbformat": 4,
254+
"nbformat_minor": 5
255+
}

0 commit comments

Comments
 (0)