Skip to content

Commit 7e4e774

Browse files
committed
Update examples.
1 parent 61e04eb commit 7e4e774

File tree

5 files changed

+185
-108
lines changed

5 files changed

+185
-108
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.. tabs::
2+
3+
.. code-tab:: python
4+
:caption: Python
5+
6+
from ads.jobs import Job, DataScienceJob, GitPythonRuntime
7+
8+
job = (
9+
Job(name="My Job")
10+
.with_infrastructure(
11+
DataScienceJob()
12+
.with_log_group_id("<log_group_ocid>")
13+
.with_log_id("<log_ocid>")
14+
# The following infrastructure configurations are optional
15+
# if you are in an OCI data science notebook session.
16+
# The configurations of the notebook session will be used as defaults.
17+
.with_compartment_id("<compartment_ocid>")
18+
.with_project_id("<project_ocid>")
19+
# For default networking, no need to specify subnet ID
20+
.with_subnet_id("<subnet_ocid>")
21+
.with_shape_name("VM.Standard.E3.Flex")
22+
# Shape config details are applicable only for the flexible shapes.
23+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24+
.with_block_storage_size(50)
25+
)
26+
.with_runtime(
27+
GitPythonRuntime()
28+
# Use service conda pack
29+
.with_service_conda("pytorch110_p38_gpu_v1")
30+
# Specify training source code from GitHub
31+
.with_source(url="https://github.com/karpathy/minGPT.git")
32+
# Entrypoint is a relative path from the root of the Git repository
33+
.with_entrypoint("demo.ipynb")
34+
)
35+
)
36+
37+
.. code-tab:: yaml
38+
:caption: YAML
39+
40+
kind: job
41+
spec:
42+
name: "My Job"
43+
infrastructure:
44+
kind: infrastructure
45+
type: dataScienceJob
46+
spec:
47+
blockStorageSize: 50
48+
compartmentId: <compartment_ocid>
49+
jobInfrastructureType: STANDALONE
50+
jobType: DEFAULT
51+
logGroupId: <log_group_ocid>
52+
logId: <log_ocid>
53+
projectId: <project_ocid>
54+
shapeConfigDetails:
55+
memoryInGBs: 16
56+
ocpus: 1
57+
shapeName: VM.Standard.E3.Flex
58+
subnetId: <subnet_ocid>
59+
runtime:
60+
kind: runtime
61+
type: gitPython
62+
spec:
63+
conda:
64+
slug: pytorch19_p37_gpu_v1
65+
type: service
66+
entrypoint: demo.ipynb
67+
url: https://github.com/karpathy/minGPT.git
68+
69+
70+
.. code-block:: python
71+
72+
# Create the job on OCI Data Science
73+
job.create()
74+
# Start a job run
75+
run = job.run()
76+
# Stream the job run outputs
77+
run.watch()

docs/source/user_guide/jobs/tabs/git_runtime.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@
66
from ads.jobs import Job, DataScienceJob, GitPythonRuntime
77

88
job = (
9-
Job(name="My Job")
10-
.with_infrastructure(
11-
DataScienceJob()
12-
.with_log_group_id("<log_group_ocid>")
13-
.with_log_id("<log_ocid>")
14-
# The following infrastructure configurations are optional
15-
# if you are in an OCI data science notebook session.
16-
# The configurations of the notebook session will be used as defaults.
17-
.with_compartment_id("<compartment_ocid>")
18-
.with_project_id("<project_ocid>")
19-
# For default networking, no need to specify subnet ID
20-
.with_subnet_id("<subnet_ocid>")
21-
.with_shape_name("VM.Standard.E3.Flex")
22-
# Shape config details are applicable only for the flexible shapes.
23-
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24-
.with_block_storage_size(50)
25-
)
26-
.with_runtime(
27-
GitPythonRuntime()
28-
.with_environment_variable(GREETINGS="Welcome to OCI Data Science")
29-
# Specify the service conda environment by slug name.
30-
.with_service_conda("pytorch19_p37_gpu_v1")
31-
# Specify the git repository
32-
# Optionally, you can specify the branch or commit
33-
.with_source("https://github.com/pytorch/tutorials.git")
34-
# Entrypoint is a relative path from the root of the git repo.
35-
.with_entrypoint("beginner_source/examples_nn/polynomial_nn.py")
36-
# Copy files in "beginner_source/examples_nn" to object storage after job finishes.
37-
.with_output(
38-
output_dir="beginner_source/examples_nn",
39-
output_uri="oci://bucket_name@namespace/path/to/dir"
9+
Job(name="My Job")
10+
.with_infrastructure(
11+
DataScienceJob()
12+
.with_log_group_id("<log_group_ocid>")
13+
.with_log_id("<log_ocid>")
14+
# The following infrastructure configurations are optional
15+
# if you are in an OCI data science notebook session.
16+
# The configurations of the notebook session will be used as defaults.
17+
.with_compartment_id("<compartment_ocid>")
18+
.with_project_id("<project_ocid>")
19+
# For default networking, no need to specify subnet ID
20+
.with_subnet_id("<subnet_ocid>")
21+
.with_shape_name("VM.Standard.E3.Flex")
22+
# Shape config details are applicable only for the flexible shapes.
23+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24+
.with_block_storage_size(50)
25+
)
26+
.with_runtime(
27+
GitPythonRuntime()
28+
.with_environment_variable(GREETINGS="Welcome to OCI Data Science")
29+
# Specify the service conda environment by slug name.
30+
.with_service_conda("pytorch19_p37_gpu_v1")
31+
# Specify the git repository
32+
# Optionally, you can specify the branch or commit
33+
.with_source("https://github.com/pytorch/tutorials.git")
34+
# Entrypoint is a relative path from the root of the git repo.
35+
.with_entrypoint("beginner_source/examples_nn/polynomial_nn.py")
36+
# Copy files in "beginner_source/examples_nn" to object storage after job finishes.
37+
.with_output(
38+
output_dir="beginner_source/examples_nn",
39+
output_uri="oci://bucket_name@namespace/path/to/dir"
40+
)
4041
)
41-
)
4242
)
4343

4444
.. code-tab:: yaml

docs/source/user_guide/jobs/tabs/name_substitution.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
from ads.jobs import Job, DataScienceJob, PythonRuntime
77

88
job = (
9-
Job(name="Training on ${DATASET_NAME}")
10-
.with_infrastructure(
11-
DataScienceJob()
12-
.with_log_group_id("<log_group_ocid>")
13-
.with_log_id("<log_ocid>")
14-
.with_compartment_id("<compartment_ocid>")
15-
.with_project_id("<project_ocid>")
16-
.with_shape_name("VM.Standard.E3.Flex")
17-
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
18-
)
19-
.with_runtime(
20-
PythonRuntime()
21-
.with_service_conda("pytorch110_p38_gpu_v1")
22-
.with_environment_variable(DATASET_NAME="MyData")
23-
.with_source("local/path/to/training_script.py")
24-
.with_output("output", "oci://bucket_name@namespace/prefix/${JOB_RUN_OCID}")
25-
)
9+
Job(name="Training on ${DATASET_NAME}")
10+
.with_infrastructure(
11+
DataScienceJob()
12+
.with_log_group_id("<log_group_ocid>")
13+
.with_log_id("<log_ocid>")
14+
.with_compartment_id("<compartment_ocid>")
15+
.with_project_id("<project_ocid>")
16+
.with_shape_name("VM.Standard.E3.Flex")
17+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
18+
)
19+
.with_runtime(
20+
PythonRuntime()
21+
.with_service_conda("pytorch110_p38_gpu_v1")
22+
.with_environment_variable(DATASET_NAME="MyData")
23+
.with_source("local/path/to/training_script.py")
24+
.with_output("output", "oci://bucket_name@namespace/prefix/${JOB_RUN_OCID}")
25+
)
2626
)
2727

2828
.. code-tab:: yaml

docs/source/user_guide/jobs/tabs/notebook_runtime.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
from ads.jobs import Job, DataScienceJob, NotebookRuntime
77

88
job = (
9-
Job(name="My Job")
10-
.with_infrastructure(
11-
DataScienceJob()
12-
.with_log_group_id("<log_group_ocid>")
13-
.with_log_id("<log_ocid>")
14-
# The following infrastructure configurations are optional
15-
# if you are in an OCI data science notebook session.
16-
# The configurations of the notebook session will be used as defaults.
17-
.with_compartment_id("<compartment_ocid>")
18-
.with_project_id("<project_ocid>")
19-
# For default networking, no need to specify subnet ID
20-
.with_subnet_id("<subnet_ocid>")
21-
.with_shape_name("VM.Standard.E3.Flex")
22-
# Shape config details are applicable only for the flexible shapes.
23-
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24-
.with_block_storage_size(50)
25-
)
26-
.with_runtime(
27-
NotebookRuntime()
28-
.with_notebook(
29-
path="https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/customization/basics.ipynb",
30-
encoding='utf-8'
9+
Job(name="My Job")
10+
.with_infrastructure(
11+
DataScienceJob()
12+
.with_log_group_id("<log_group_ocid>")
13+
.with_log_id("<log_ocid>")
14+
# The following infrastructure configurations are optional
15+
# if you are in an OCI data science notebook session.
16+
# The configurations of the notebook session will be used as defaults.
17+
.with_compartment_id("<compartment_ocid>")
18+
.with_project_id("<project_ocid>")
19+
# For default networking, no need to specify subnet ID
20+
.with_subnet_id("<subnet_ocid>")
21+
.with_shape_name("VM.Standard.E3.Flex")
22+
# Shape config details are applicable only for the flexible shapes.
23+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24+
.with_block_storage_size(50)
25+
)
26+
.with_runtime(
27+
NotebookRuntime()
28+
.with_notebook(
29+
path="https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/customization/basics.ipynb",
30+
encoding='utf-8'
31+
)
32+
.with_service_conda("tensorflow28_p38_cpu_v1")
33+
.with_environment_variable(GREETINGS="Welcome to OCI Data Science")
34+
.with_exclude_tag(["ignore", "remove"])
35+
.with_output("oci://bucket_name@namespace/path/to/dir")
3136
)
32-
.with_service_conda("tensorflow28_p38_cpu_v1")
33-
.with_environment_variable(GREETINGS="Welcome to OCI Data Science")
34-
.with_exclude_tag(["ignore", "remove"])
35-
.with_output("oci://bucket_name@namespace/path/to/dir")
36-
)
3737
)
3838

3939
.. code-tab:: yaml

docs/source/user_guide/jobs/tabs/script_runtime.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@
66
from ads.jobs import Job, DataScienceJob, ScriptRuntime
77

88
job = (
9-
Job(name="My Job")
10-
.with_infrastructure(
11-
DataScienceJob()
12-
.with_log_group_id("<log_group_ocid>")
13-
.with_log_id("<log_ocid>")
14-
# The following infrastructure configurations are optional
15-
# if you are in an OCI data science notebook session.
16-
# The configurations of the notebook session will be used as defaults.
17-
.with_compartment_id("<compartment_ocid>")
18-
.with_project_id("<project_ocid>")
19-
# For default networking, no need to specify subnet ID
20-
.with_subnet_id("<subnet_ocid>")
21-
.with_shape_name("VM.Standard.E3.Flex")
22-
# Shape config details are applicable only for the flexible shapes.
23-
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24-
.with_block_storage_size(50)
25-
)
26-
.with_runtime(
27-
ScriptRuntime()
28-
# Specify the service conda environment by slug name.
29-
.with_service_conda("pytorch110_p38_cpu_v1")
30-
# The job artifact can be a single Python script, a directory or a zip file.
31-
.with_source("local/path/to/code_dir")
32-
# Environment variable
33-
.with_environment_variable(NAME="Welcome to OCI Data Science.")
34-
# Command line argument
35-
.with_argument("100 linux \"hi there\"")
36-
# The entrypoint is applicable only to directory or zip file as source
37-
# The entrypoint should be a path relative to the working dir.
38-
# Here my_script.sh is a file in the code_dir/my_package directory
39-
.with_entrypoint("my_package/my_script.sh")
40-
)
9+
Job(name="My Job")
10+
.with_infrastructure(
11+
DataScienceJob()
12+
.with_log_group_id("<log_group_ocid>")
13+
.with_log_id("<log_ocid>")
14+
# The following infrastructure configurations are optional
15+
# if you are in an OCI data science notebook session.
16+
# The configurations of the notebook session will be used as defaults.
17+
.with_compartment_id("<compartment_ocid>")
18+
.with_project_id("<project_ocid>")
19+
# For default networking, no need to specify subnet ID
20+
.with_subnet_id("<subnet_ocid>")
21+
.with_shape_name("VM.Standard.E3.Flex")
22+
# Shape config details are applicable only for the flexible shapes.
23+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
24+
.with_block_storage_size(50)
25+
)
26+
.with_runtime(
27+
ScriptRuntime()
28+
# Specify the service conda environment by slug name.
29+
.with_service_conda("pytorch110_p38_cpu_v1")
30+
# The job artifact can be a single Python script, a directory or a zip file.
31+
.with_source("local/path/to/code_dir")
32+
# Environment variable
33+
.with_environment_variable(NAME="Welcome to OCI Data Science.")
34+
# Command line argument
35+
.with_argument("100 linux \"hi there\"")
36+
# The entrypoint is applicable only to directory or zip file as source
37+
# The entrypoint should be a path relative to the working dir.
38+
# Here my_script.sh is a file in the code_dir/my_package directory
39+
.with_entrypoint("my_package/my_script.sh")
40+
)
4141
)
4242

4343
.. code-tab:: yaml

0 commit comments

Comments
 (0)