Skip to content

Commit 02aafa5

Browse files
authored
Merge pull request #1 from virtualcell/vcell-api-client
add vcell api client
2 parents 6aa01ea + 5001a8a commit 02aafa5

File tree

166 files changed

+20684
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+20684
-1079
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
strategy:
3131
matrix:
32-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
32+
python-version: ["3.9", "3.10", "3.11", "3.12"]
3333
fail-fast: false
3434
defaults:
3535
run:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,7 @@ cython_debug/
169169
.idea/
170170

171171
test_output_1/
172+
173+
.python-version
174+
175+
**/.DS_Store

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repos:
1414
hooks:
1515
- id: ruff
1616
args: [--exit-non-zero-on-fix]
17+
exclude: 'pyvcell/api/.*\.py'
1718
- id: ruff-format
1819

1920
- repo: https://github.com/pre-commit/mirrors-prettier

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ check: ## Run code quality tools.
1414
@echo "🚀 Static type checking: Running mypy"
1515
@poetry run mypy
1616
@echo "🚀 Checking for obsolete dependencies: Running deptry"
17-
@poetry run deptry .
17+
@poetry run deptry --exclude .venv .
1818

1919
.PHONY: test
2020
test: ## Test the code with pytest

docs/modules.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
::: pyvcell.foo
1+
# Modules
2+
3+
## pyvcell
4+
5+
::: pyvcell
6+
handler: python
7+
options:
8+
show_root_heading: true
9+
show_source: true
10+
show_signature_annotations: true

examples/vcell_publications.ipynb

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"source": [
6+
"from pyvcell.api.vcell_client import ApiClient, Configuration, PublicationResourceApi\n",
7+
"from pyvcell.api.vcell_client.auth.auth_utils import login_interactive\n",
8+
"from pyvcell.api.vcell_client.models import Publication"
9+
],
10+
"metadata": {
11+
"collapsed": false,
12+
"ExecuteTime": {
13+
"end_time": "2025-01-23T07:43:37.703710Z",
14+
"start_time": "2025-01-23T07:43:37.701027Z"
15+
}
16+
},
17+
"id": "5e183b4a68315dfe",
18+
"outputs": [],
19+
"execution_count": 2
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"source": [
24+
"# VCell API Client usage\n",
25+
"1. as a public user (no authentication)\n",
26+
"2. as an authenticated user (with authentication)"
27+
],
28+
"metadata": {
29+
"collapsed": false
30+
},
31+
"id": "d11f5830839dbfb4"
32+
},
33+
{
34+
"cell_type": "markdown",
35+
"source": [
36+
"## 1) Create anonymous API Client - access to public resources"
37+
],
38+
"metadata": {
39+
"collapsed": false
40+
},
41+
"id": "524d1696c6c50b83"
42+
},
43+
{
44+
"cell_type": "code",
45+
"source": [
46+
"api_url: str = \"https://vcell-dev.cam.uchc.edu\" # vcell base url\n",
47+
"\n",
48+
"public_client = ApiClient(configuration=Configuration(host=api_url))"
49+
],
50+
"metadata": {
51+
"collapsed": false,
52+
"ExecuteTime": {
53+
"end_time": "2025-01-23T07:43:37.725514Z",
54+
"start_time": "2025-01-23T07:43:37.723335Z"
55+
}
56+
},
57+
"id": "902c6d3a8dc70af",
58+
"outputs": [],
59+
"execution_count": 3
60+
},
61+
{
62+
"cell_type": "markdown",
63+
"source": [
64+
"### Test Publication API - without authentication\n",
65+
"1. get publications - doesn't need authentication/authorization"
66+
],
67+
"metadata": {
68+
"collapsed": false
69+
},
70+
"id": "b12dfb281d589869"
71+
},
72+
{
73+
"cell_type": "code",
74+
"source": [
75+
"public_publication_api = PublicationResourceApi(public_client)\n",
76+
"pubs: list[Publication] = public_publication_api.get_publications()\n",
77+
"display(pubs[0])"
78+
],
79+
"metadata": {
80+
"collapsed": false,
81+
"ExecuteTime": {
82+
"end_time": "2025-01-23T07:43:38.028844Z",
83+
"start_time": "2025-01-23T07:43:37.735773Z"
84+
}
85+
},
86+
"id": "9ba5b1ac2df17231",
87+
"outputs": [
88+
{
89+
"data": {
90+
"text/plain": [
91+
"Publication(pub_key=279906235, title='A continuum model of mechanosensation based on contractility kit assembly', authors=['Dolgitzer', ' D.', ' Plaza-Rodríguez', ' A. I.', ' Iglesias', ' M. A.', ' Jacob', ' M. A. C.', ' Todd', ' B.', ' Robinson', ' D. N.', ' & Iglesias', ' P. A.'], year=2024, citation='Biophys J. 2024 Nov 8:S0006-3495(24)00708-2', pubmedid='39521955', doi='https://doi.org/10.1016/j.bpj.2024.10.020', endnoteid=0, url='url', wittid=0, biomodel_refs=[BiomodelRef(bm_key=279851639, name='Dolgitzer 2025 A Continuum Model of Mechanosensation Based on Contractility Kit Assembly', owner_name='Dolgitzer', owner_key=259537152, version_flag=3)], mathmodel_refs=[], var_date=datetime.date(2024, 11, 26))"
92+
]
93+
},
94+
"metadata": {},
95+
"output_type": "display_data"
96+
}
97+
],
98+
"execution_count": 4
99+
},
100+
{
101+
"cell_type": "markdown",
102+
"source": [
103+
"## 2) invoke VCell API as an authenticated user\n",
104+
"This will open a browser window to login into VCell using Auth0. After login, the browser will redirect to the VCell webapp '/success_login'. `api_client` will be authenticated for VCell API requests. "
105+
],
106+
"metadata": {
107+
"collapsed": false
108+
},
109+
"id": "6444e342beaccd4d"
110+
},
111+
{
112+
"cell_type": "code",
113+
"id": "f56d96abf59682dd",
114+
"metadata": {
115+
"collapsed": false,
116+
"ExecuteTime": {
117+
"end_time": "2025-01-23T07:43:46.823079Z",
118+
"start_time": "2025-01-23T07:43:38.037782Z"
119+
}
120+
},
121+
"source": [
122+
"client_id: str = 'cjoWhd7W8A8znf7Z7vizyvKJCiqTgRtf' # default client id for standalone VCell clients\n",
123+
"issuer_url: str = 'https://dev-dzhx7i2db3x3kkvq.us.auth0.com' # Auth0 issuer url for VCell\n",
124+
"\n",
125+
"authenticated_client = login_interactive(api_base_url=api_url, client_id=client_id, issuer_url=issuer_url)\n",
126+
"display(\"may loose focus to the browser window for login, switch back to this notebook after login.\")"
127+
],
128+
"outputs": [
129+
{
130+
"data": {
131+
"text/plain": [
132+
"'may loose focus to the browser window for login, switch back to this notebook after login.'"
133+
]
134+
},
135+
"metadata": {},
136+
"output_type": "display_data"
137+
}
138+
],
139+
"execution_count": 5
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"id": "a0e558b807038809",
144+
"metadata": {
145+
"collapsed": false
146+
},
147+
"source": [
148+
"### Test Publication API\n",
149+
"1. get publications - also doesn't need authentication/authorization"
150+
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"id": "8f95b36e4437ccbb",
155+
"metadata": {
156+
"collapsed": false,
157+
"ExecuteTime": {
158+
"end_time": "2025-01-23T07:43:47.020349Z",
159+
"start_time": "2025-01-23T07:43:46.852654Z"
160+
}
161+
},
162+
"source": [
163+
"publication_api = PublicationResourceApi(authenticated_client)\n",
164+
"pubs: list[Publication] = publication_api.get_publications()\n",
165+
"display(pubs[0])"
166+
],
167+
"outputs": [
168+
{
169+
"data": {
170+
"text/plain": [
171+
"Publication(pub_key=279906235, title='A continuum model of mechanosensation based on contractility kit assembly', authors=['Dolgitzer', ' D.', ' Plaza-Rodríguez', ' A. I.', ' Iglesias', ' M. A.', ' Jacob', ' M. A. C.', ' Todd', ' B.', ' Robinson', ' D. N.', ' & Iglesias', ' P. A.'], year=2024, citation='Biophys J. 2024 Nov 8:S0006-3495(24)00708-2', pubmedid='39521955', doi='https://doi.org/10.1016/j.bpj.2024.10.020', endnoteid=0, url='url', wittid=0, biomodel_refs=[BiomodelRef(bm_key=279851639, name='Dolgitzer 2025 A Continuum Model of Mechanosensation Based on Contractility Kit Assembly', owner_name='Dolgitzer', owner_key=259537152, version_flag=3)], mathmodel_refs=[], var_date=datetime.date(2024, 11, 26))"
172+
]
173+
},
174+
"metadata": {},
175+
"output_type": "display_data"
176+
}
177+
],
178+
"execution_count": 6
179+
},
180+
{
181+
"cell_type": "code",
182+
"id": "ed266f9194abb748",
183+
"metadata": {
184+
"collapsed": false,
185+
"ExecuteTime": {
186+
"end_time": "2025-01-23T07:43:47.026801Z",
187+
"start_time": "2025-01-23T07:43:47.025477Z"
188+
}
189+
},
190+
"source": [],
191+
"outputs": [],
192+
"execution_count": null
193+
}
194+
],
195+
"metadata": {
196+
"kernelspec": {
197+
"display_name": "Python 3 (ipykernel)",
198+
"language": "python",
199+
"name": "python3"
200+
},
201+
"language_info": {
202+
"codemirror_mode": {
203+
"name": "ipython",
204+
"version": 3
205+
},
206+
"file_extension": ".py",
207+
"mimetype": "text/x-python",
208+
"name": "python",
209+
"nbconvert_exporter": "python",
210+
"pygments_lexer": "ipython3",
211+
"version": "3.12.2"
212+
}
213+
},
214+
"nbformat": 4,
215+
"nbformat_minor": 5
216+
}

0 commit comments

Comments
 (0)