Skip to content

Commit 13eb942

Browse files
committed
minor updates
1 parent ea124f6 commit 13eb942

File tree

4 files changed

+133
-164
lines changed

4 files changed

+133
-164
lines changed

pipelines/samples/employee-attrition/employee-attrition-pipeline-ads.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "c8a4f0d9",
77
"metadata": {},
88
"source": [
9-
"# Employee attrition sample using ML Pipelines"
9+
"# Employee attrition sample using ML Pipelines with ADS"
1010
]
1111
},
1212
{

pipelines/samples/employee-attrition/employee-attrition-pipeline.ipynb

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,49 @@
8585
"import oci\n",
8686
"import ads\n",
8787
"import os\n",
88-
"from os import environ\n",
89-
"from ads.catalog.project import ProjectCatalog\n",
90-
"\n",
91-
"ads.set_auth(auth='resource_principal')"
88+
"from os import environ"
9289
]
9390
},
9491
{
9592
"cell_type": "code",
9693
"execution_count": null,
97-
"id": "7d72637e",
94+
"id": "f841d08d",
9895
"metadata": {
9996
"vscode": {
10097
"languageId": "python"
10198
}
10299
},
103100
"outputs": [],
104101
"source": [
105-
"# make sure there is access to the project and compartment\n",
106-
"compartment_id = os.environ['NB_SESSION_COMPARTMENT_OCID']\n",
107-
"pc = ProjectCatalog(compartment_id=compartment_id)\n",
108-
"pc.list_projects()"
102+
"if 'NB_SESSION_COMPARTMENT_OCID' in os.environ:\n",
103+
" # using the notebook's compartment if running on OCI Data Science Notebook Session\n",
104+
" compartment_id = os.environ['NB_SESSION_COMPARTMENT_OCID']\n",
105+
"else:\n",
106+
" # set the compartment OCID if you are working locally\n",
107+
" compartment_id = '<YOUR_COMPARTMENT_OCID>'\n",
108+
"print('compartment OCID = ', compartment_id)"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": null,
114+
"id": "ec3398d8",
115+
"metadata": {
116+
"vscode": {
117+
"languageId": "python"
118+
}
119+
},
120+
"outputs": [],
121+
"source": [
122+
"# this will work whether working on a local machine (using API key) or in OCI Notebook Session (using Resource Principal)\n",
123+
"if \"OCI_RESOURCE_PRINCIPAL_VERSION\" in os.environ:\n",
124+
" # Use resource principal\n",
125+
" print(\"using Resource Principal for auth\")\n",
126+
" ads.set_auth(auth=\"resource_principal\")\n",
127+
"else:\n",
128+
" # Use api_key with config file\n",
129+
" print(\"using API key for auth\")\n",
130+
" ads.set_auth(auth=\"api_key\") "
109131
]
110132
},
111133
{
@@ -145,20 +167,6 @@
145167
"log_group_id = \"<YOUR_LOG_GROUP_ID>\""
146168
]
147169
},
148-
{
149-
"cell_type": "code",
150-
"execution_count": null,
151-
"id": "19a7855a",
152-
"metadata": {
153-
"vscode": {
154-
"languageId": "python"
155-
}
156-
},
157-
"outputs": [],
158-
"source": [
159-
"data_location = \"<YOUR_OBJECT_STORAGE_LOCATION_TO_PASS_DATA>\" # use: 'oci://<bucket>@<workspace>/'"
160-
]
161-
},
162170
{
163171
"cell_type": "code",
164172
"execution_count": null,
@@ -254,8 +262,7 @@
254262
" \"environmentVariables\": {\n",
255263
" \"PIPELINE_STEP_RUN_ENTRYPOINT\": \"employee-attr-dataproc.py\",\n",
256264
" \"CONDA_ENV_TYPE\": \"service\",\n",
257-
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\",\n",
258-
" \"DATA_LOCATION\": data_location\n",
265+
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\"\n",
259266
" }\n",
260267
" }\n",
261268
" },\n",
@@ -273,8 +280,7 @@
273280
" \"environmentVariables\": {\n",
274281
" \"PIPELINE_STEP_RUN_ENTRYPOINT\": \"employee-attr-train-lr.py\",\n",
275282
" \"CONDA_ENV_TYPE\": \"service\",\n",
276-
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\",\n",
277-
" \"DATA_LOCATION\": data_location\n",
283+
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\"\n",
278284
" }\n",
279285
" },\n",
280286
" \"dependsOn\": [\"data_processing\"]\n",
@@ -293,8 +299,7 @@
293299
" \"environmentVariables\": {\n",
294300
" \"PIPELINE_STEP_RUN_ENTRYPOINT\": \"employee-attr-train-rf.py\",\n",
295301
" \"CONDA_ENV_TYPE\": \"service\",\n",
296-
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\",\n",
297-
" \"DATA_LOCATION\": data_location\n",
302+
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\"\n",
298303
" }\n",
299304
" },\n",
300305
" \"dependsOn\": [\"data_processing\"]\n",
@@ -313,8 +318,7 @@
313318
" \"environmentVariables\": {\n",
314319
" \"PIPELINE_STEP_RUN_ENTRYPOINT\": \"employee-attr-train-xgb.py\",\n",
315320
" \"CONDA_ENV_TYPE\": \"service\",\n",
316-
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\",\n",
317-
" \"DATA_LOCATION\": data_location\n",
321+
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\"\n",
318322
" }\n",
319323
" },\n",
320324
" \"dependsOn\": [\"data_processing\"]\n",
@@ -333,8 +337,7 @@
333337
" \"environmentVariables\": {\n",
334338
" \"PIPELINE_STEP_RUN_ENTRYPOINT\": \"employee-attr-eval-deploy.py\",\n",
335339
" \"CONDA_ENV_TYPE\": \"service\",\n",
336-
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\",\n",
337-
" \"DATA_LOCATION\": data_location\n",
340+
" \"CONDA_ENV_SLUG\": \"generalml_p37_cpu_v1\"\n",
338341
" }\n",
339342
" },\n",
340343
" \"dependsOn\": [\"train_logistic_regression\", \"train_random_forest\", \"train_xgboost\"]\n",
@@ -410,7 +413,7 @@
410413
"for name in steps_names_and_artifacts:\n",
411414
" fl = open(steps_names_and_artifacts[name], \"rb\")\n",
412415
" ret = data_science_client.create_step_artifact(pipeline_id, name, fl, content_disposition=f\"attachment; filename={steps_names_and_artifacts[name]}\")\n",
413-
" print(\"OK\" if ret.status==204 else ret.status) # 204 is ok"
416+
" print(f\"{steps_names_and_artifacts[name]}: OK\" if ret.status==204 else f\"{steps_names_and_artifacts[name]}: {ret.status}\") # 204 is ok"
414417
]
415418
},
416419
{
@@ -452,6 +455,21 @@
452455
"pipeline_run_name = f\"pipeline-run-{randrange(1000,9999)}\""
453456
]
454457
},
458+
{
459+
"cell_type": "code",
460+
"execution_count": null,
461+
"id": "ac586f6b",
462+
"metadata": {
463+
"vscode": {
464+
"languageId": "python"
465+
}
466+
},
467+
"outputs": [],
468+
"source": [
469+
"# uncomment the next line and set to the OCI Object Storage location to use for passing data. Make sure you have proper permissions.\n",
470+
"#data_location = \"<YOUR_OBJECT_STORAGE_BUCKET>\" # use: 'oci://<bucket>@<workspace>/'"
471+
]
472+
},
455473
{
456474
"cell_type": "code",
457475
"execution_count": null,

pipelines/samples/simple/mlpipeline_sample-ads.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"id": "22859d56",
67
"metadata": {},
78
"source": [
8-
"### OCI Data Science - ML Pipelines sample notebook\n",
9+
"### OCI Data Science - ML Pipelines sample notebook with ADS\n",
910
"\n",
1011
"This sample notebook demonstrates how to use ADS to create a pipeline with 3 steps:\n",
1112
" * the first step sets a paramter for the next step\n",

0 commit comments

Comments
 (0)