Skip to content

Commit 393ef03

Browse files
committed
update: set owner_id to org if present (confirmed on pyodide)
1 parent 565b4a0 commit 393ef03

9 files changed

+39
-31
lines changed

examples/job/create_and_submit_job.ipynb

+3-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@
181181
},
182182
"outputs": [],
183183
"source": [
184-
"default_material = material_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0]\n",
185-
"default_workflow = workflow_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0]\n",
184+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
185+
"default_material = material_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0]\n",
186+
"default_workflow = workflow_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0]\n",
186187
"\n",
187188
"material_id = default_material[\"_id\"]\n",
188189
"workflow_id = default_workflow[\"_id\"]\n",

examples/job/get-file-from-job.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
"source": [
193193
"# Get some account information\n",
194194
"project_endpoints = ProjectEndpoints(*ENDPOINT_ARGS)\n",
195-
"project_metadata = project_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0]\n",
195+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
196+
"project_metadata = project_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0]\n",
196197
"project_id = project_metadata[\"_id\"]\n",
197198
"owner_id = project_metadata[\"owner\"][\"_id\"]\n",
198199
"\n",

examples/job/ml-train-model-predict-properties.ipynb

+3-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@
295295
},
296296
"outputs": [],
297297
"source": [
298-
"owner_id = material_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0][\"owner\"][\"_id\"]\n",
299-
"project_id = project_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0][\"_id\"]"
298+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
299+
"owner_id = material_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0][\"owner\"][\"_id\"]\n",
300+
"project_id = project_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0][\"_id\"]"
300301
]
301302
},
302303
{

examples/job/run-simulations-and-extract-properties.ipynb

+3-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,9 @@
347347
},
348348
"outputs": [],
349349
"source": [
350-
"owner_id = material_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0][\"owner\"][\"_id\"]\n",
351-
"project_id = project_endpoints.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})[0][\"_id\"]"
350+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
351+
"owner_id = material_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0][\"owner\"][\"_id\"]\n",
352+
"project_id = project_endpoints.list({\"isDefault\": True, \"owner._id\": OWNER_ID})[0][\"_id\"]"
352353
]
353354
},
354355
{

examples/material/create_material.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@
190190
},
191191
"outputs": [],
192192
"source": [
193+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
193194
"endpoint = MaterialEndpoints(*ENDPOINT_ARGS)\n",
194-
"material = endpoint.create(CONFIG)"
195+
"material = endpoint.create(CONFIG, OWNER_ID)"
195196
]
196197
},
197198
{

examples/material/get_materials_by_formula.ipynb

+19-20
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@
4848
},
4949
{
5050
"cell_type": "code",
51-
"execution_count": null,
5251
"metadata": {
5352
"cellView": "form",
5453
"id": "LbQQf3GpCzPD"
5554
},
56-
"outputs": [],
5755
"source": [
5856
"# @title Authorization Form\n",
5957
"ACCOUNT_ID = \"ACCOUNT_ID\" # @param {type:\"string\"}\n",
@@ -95,7 +93,9 @@
9593
" from utils.jupyterlite import install_packages\n",
9694
"\n",
9795
" await install_packages(\"\")"
98-
]
96+
],
97+
"outputs": [],
98+
"execution_count": null
9999
},
100100
{
101101
"attachments": {},
@@ -109,17 +109,17 @@
109109
},
110110
{
111111
"cell_type": "code",
112-
"execution_count": null,
113112
"metadata": {
114113
"id": "kMwJxlkQCzPE"
115114
},
116-
"outputs": [],
117115
"source": [
118116
"from utils.settings import ENDPOINT_ARGS, ACCOUNT_ID\n",
119117
"from utils.generic import display_JSON\n",
120118
"\n",
121119
"from exabyte_api_client.endpoints.materials import MaterialEndpoints"
122-
]
120+
],
121+
"outputs": [],
122+
"execution_count": null
123123
},
124124
{
125125
"attachments": {},
@@ -135,14 +135,15 @@
135135
},
136136
{
137137
"cell_type": "code",
138-
"execution_count": null,
139138
"metadata": {
140139
"id": "KZWqlxVcCzPF"
141140
},
142-
"outputs": [],
143141
"source": [
144-
"QUERY = {\"formula\": \"Si\", \"owner._id\": ACCOUNT_ID}"
145-
]
142+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
143+
"QUERY = {\"formula\": \"Si\", \"ownerId\": OWNER_ID}"
144+
],
145+
"outputs": [],
146+
"execution_count": null
146147
},
147148
{
148149
"attachments": {},
@@ -156,14 +157,12 @@
156157
},
157158
{
158159
"cell_type": "code",
159-
"execution_count": null,
160160
"metadata": {
161161
"id": "dolF1C6-CzPG"
162162
},
163+
"source": "endpoint = MaterialEndpoints(*ENDPOINT_ARGS)",
163164
"outputs": [],
164-
"source": [
165-
"endpoint = MaterialEndpoints(*ENDPOINT_ARGS)"
166-
]
165+
"execution_count": null
167166
},
168167
{
169168
"attachments": {},
@@ -179,14 +178,14 @@
179178
},
180179
{
181180
"cell_type": "code",
182-
"execution_count": null,
183181
"metadata": {
184182
"id": "IE-K3TexCzPH"
185183
},
186-
"outputs": [],
187184
"source": [
188185
"materials = endpoint.list(QUERY)"
189-
]
186+
],
187+
"outputs": [],
188+
"execution_count": null
190189
},
191190
{
192191
"attachments": {},
@@ -202,17 +201,17 @@
202201
},
203202
{
204203
"cell_type": "code",
205-
"execution_count": null,
206204
"metadata": {
207205
"id": "LRVpf37eCzPH",
208206
"pycharm": {
209207
"name": "#%%\n"
210208
}
211209
},
212-
"outputs": [],
213210
"source": [
214211
"display_JSON(materials)"
215-
]
212+
],
213+
"outputs": [],
214+
"execution_count": null
216215
}
217216
],
218217
"metadata": {

examples/material/upload_materials_from_file_poscar.ipynb

+3-1
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@
174174
" content = f.read()\n",
175175
" print(content)\n",
176176
"\n",
177+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
178+
"\n",
177179
"endpoint = MaterialEndpoints(*ENDPOINT_ARGS)\n",
178-
"material = endpoint.import_from_file(NAME, content)"
180+
"material = endpoint.import_from_file(NAME, content, owner_id=OWNER_ID)"
179181
]
180182
},
181183
{

examples/workflow/get_workflows.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
},
148148
"outputs": [],
149149
"source": [
150-
"QUERY = {\"name\": \"Total Energy\", \"owner._id\": ACCOUNT_ID}\n",
150+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
151+
"QUERY = {\"name\": \"Total Energy\", \"owner._id\": OWNER_ID}\n",
151152
"\n",
152153
"OPTIONS = {\"limit\": 2}"
153154
]

examples/workflow/qe_scf_calculation.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@
223223
"outputs": [],
224224
"source": [
225225
"# create workflow\n",
226-
"WORKFLOW_RESP = workflow_endpoints.create(WORKFLOW_BODY)"
226+
"OWNER_ID = os.getenv(\"ORGANIZATION_ID\") or ACCOUNT_ID\n",
227+
"WORKFLOW_RESP = workflow_endpoints.create(WORKFLOW_BODY, owner_id=OWNER_ID)"
227228
]
228229
},
229230
{

0 commit comments

Comments
 (0)