Skip to content

Commit 611e946

Browse files
committed
Update code examples.
1 parent 6ddb3ca commit 611e946

File tree

7 files changed

+104
-79
lines changed

7 files changed

+104
-79
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
)
3333
)
3434

35-
# Create the job on OCI Data Science
36-
job.create()
37-
# Start a job run
38-
run = job.run()
39-
# Stream the job run outputs
40-
run.watch()
41-
4235
.. code-tab:: yaml
4336
:caption: YAML
4437

@@ -72,4 +65,14 @@
7265
env:
7366
- name: GREETINGS
7467
value: Welcome to OCI Data Science
75-
image: <region>.ocir.io/<your_tenancy>/<your_image>
68+
image: <region>.ocir.io/<your_tenancy>/<your_image>
69+
70+
71+
.. code-block:: python
72+
73+
# Create the job on OCI Data Science
74+
job.create()
75+
# Start a job run
76+
run = job.run()
77+
# Stream the job run outputs
78+
run.watch()

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@
4141
)
4242
)
4343

44-
# Create the job on OCI Data Science
45-
job.create()
46-
# Start a job run
47-
run = job.run()
48-
# Stream the job run outputs
49-
run.watch()
50-
5144
.. code-tab:: yaml
5245
:caption: YAML
5346

@@ -83,4 +76,14 @@
8376
value: Welcome to OCI Data Science
8477
outputDir: beginner_source/examples_nn
8578
outputUri: oci://bucket_name@namespace/path/to/dir
86-
url: https://github.com/pytorch/tutorials.git
79+
url: https://github.com/pytorch/tutorials.git
80+
81+
82+
.. code-block:: python
83+
84+
# Create the job on OCI Data Science
85+
job.create()
86+
# Start a job run
87+
run = job.run()
88+
# Stream the job run outputs
89+
run.watch()

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@
3636
)
3737
)
3838

39-
# Create the job on OCI Data Science
40-
job.create()
41-
# Start a job run
42-
run = job.run()
43-
# Stream the job run outputs
44-
run.watch()
45-
# Download the notebook back to local
46-
run.download("/path/to/local/dir")
47-
4839
.. code-tab:: yaml
4940
:caption: YAML
5041

@@ -82,4 +73,15 @@
8273
- remove
8374
notebookEncoding: utf-8
8475
notebookPathURI: https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/customization/basics.ipynb
85-
outputUri: oci://bucket_name@namespace/path/to/dir
76+
outputUri: oci://bucket_name@namespace/path/to/dir
77+
78+
.. code-block:: python
79+
80+
# Create the job on OCI Data Science
81+
job.create()
82+
# Start a job run
83+
run = job.run()
84+
# Stream the job run outputs
85+
run.watch()
86+
# Download the notebook back to local
87+
run.download("/path/to/local/dir")

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

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,48 @@
66
from ads.jobs import Job, DataScienceJob, PythonRuntime
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-
PythonRuntime()
28-
# Specify the service conda environment by slug name.
29-
.with_service_conda("pytorch19_p37_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-
# Set the working directory
33-
# When using a directory as source, the default working dir is the parent of code_dir.
34-
# Working dir should be a relative path beginning from the source directory (code_dir)
35-
.with_working_dir("code_dir")
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.py is a file in the code_dir/my_package directory
39-
.with_entrypoint("my_package/my_script.py")
40-
# Add an additional Python path, relative to the working dir (code_dir/other_packages).
41-
.with_python_path("other_packages")
42-
# Copy files in "code_dir/output" to object storage after job finishes.
43-
.with_output("output", "oci://bucket_name@namespace/path/to/dir")
44-
)
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+
PythonRuntime()
28+
# Specify the service conda environment by slug name.
29+
.with_service_conda("pytorch19_p37_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, arg1 --key arg2
35+
.with_argument("arg1", key="arg2")
36+
# Set the working directory
37+
# When using a directory as source, the default working dir is the parent of code_dir.
38+
# Working dir should be a relative path beginning from the source directory (code_dir)
39+
.with_working_dir("code_dir")
40+
# The entrypoint is applicable only to directory or zip file as source
41+
# The entrypoint should be a path relative to the working dir.
42+
# Here my_script.py is a file in the code_dir/my_package directory
43+
.with_entrypoint("my_package/my_script.py")
44+
# Add an additional Python path, relative to the working dir (code_dir/other_packages).
45+
.with_python_path("other_packages")
46+
# Copy files in "code_dir/output" to object storage after job finishes.
47+
.with_output("output", "oci://bucket_name@namespace/path/to/dir")
48+
)
4549
)
4650

47-
# Create the job on OCI Data Science
48-
job.create()
49-
# Start a job run
50-
run = job.run()
51-
# Stream the job run outputs
52-
run.watch()
53-
5451
.. code-tab:: yaml
5552
:caption: YAML
5653

@@ -77,13 +74,31 @@
7774
kind: runtime
7875
type: python
7976
spec:
77+
args:
78+
- arg1
79+
- --key
80+
- arg2
8081
conda:
8182
slug: pytorch19_p37_cpu_v1
8283
type: service
8384
entrypoint: my_package/my_script.py
85+
env:
86+
- name: NAME
87+
value: Welcome to OCI Data Science.
8488
outputDir: output
8589
outputUri: oci://bucket_name@namespace/path/to/dir
8690
pythonPath:
8791
- other_packages
8892
scriptPathURI: local/path/to/code_dir
89-
workingDir: code_dir
93+
workingDir: code_dir
94+
workingDir: code_dir
95+
96+
97+
.. code-block:: python
98+
99+
# Create the job on OCI Data Science
100+
job.create()
101+
# Start a job run
102+
run = job.run()
103+
# Stream the job run outputs
104+
run.watch()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
.. code-block:: python
8181
8282
print(runtime.args)
83-
# ["pos1", "--key1", "--key2", "val2", "pos2"]
83+
# ["pos1", "--key1", "--key2", "val2", "pos2"]

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
)
3737
)
3838

39-
# Create the job on OCI Data Science
40-
job.create()
41-
# Start a job run
42-
run = job.run()
43-
# Stream the job run outputs
44-
run.watch()
45-
4639
.. code-tab:: yaml
4740
:caption: YAML
4841

@@ -74,3 +67,12 @@
7467
type: service
7568
entrypoint: my_package/my_script.sh
7669
scriptPathURI: local/path/to/code_dir
70+
71+
.. code-block:: python
72+
73+
# Create the job on OCI Data Science
74+
job.create()
75+
# Start a job run
76+
run = job.run()
77+
# Stream the job run outputs
78+
run.watch()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@
7575
value: Welcome to OCI Data Science
7676
outputDir: beginner_source/examples_nn
7777
outputUri: oci://bucket_name@namespace/path/to/dir
78-
url: https://github.com/pytorch/tutorials.git
78+
url: https://github.com/pytorch/tutorials.git

0 commit comments

Comments
 (0)