Skip to content

Commit d18fca0

Browse files
committed
Adjusts the operators documentation.
1 parent b94c9a6 commit d18fca0

File tree

6 files changed

+159
-22
lines changed

6 files changed

+159
-22
lines changed

ads/opctl/operator/cmd.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
from .__init__ import __operators__
4040
from .common import utils as operator_utils
4141
from .common.backend_factory import BackendFactory
42-
from .common.errors import OperatorCondaNotFoundError, OperatorImageNotFoundError
42+
from .common.errors import (
43+
OperatorCondaNotFoundError,
44+
OperatorImageNotFoundError,
45+
OperatorSchemaYamlError,
46+
)
4347
from .common.operator_loader import _operator_info_list
4448

4549

@@ -160,18 +164,20 @@ def init(
160164
output = os.path.join(tempfile.TemporaryDirectory().name, "")
161165

162166
# generating operator specification
163-
operator_config = None
167+
operator_config = {}
164168
try:
165169
operator_cmd_module = runpy.run_module(
166170
f"{operator_info.type}.cmd", run_name="init"
167171
)
168172
operator_config = operator_cmd_module.get("init", lambda: "")(
169173
**{**kwargs, **{"type": type}}
170174
)
171-
with fsspec.open(
172-
os.path.join(output, f"{operator_info.type}.yaml"), mode="w"
173-
) as f:
174-
f.write(yaml.dump(operator_config))
175+
176+
if not merge_config:
177+
with fsspec.open(
178+
os.path.join(output, f"{operator_info.type}.yaml"), mode="w"
179+
) as f:
180+
f.write(yaml.dump(operator_config))
175181
except Exception as ex:
176182
logger.info(
177183
"The operator's specification was not generated "
@@ -407,7 +413,12 @@ def verify(
407413
run_name="verify",
408414
)
409415
operator_module.get("verify")(config, **kwargs)
410-
416+
except OperatorSchemaYamlError as ex:
417+
logger.debug(ex)
418+
raise ValueError(
419+
f"The operator's specification is not valid for the `{operator_info.type}` operator. "
420+
f"{ex}"
421+
)
411422
except Exception as ex:
412423
logger.debug(ex)
413424
raise ValueError(

ads/opctl/operator/common/operator_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def _validate_dict(cls, obj_dict: Dict) -> bool:
6161
"""
6262
schema = cls._load_schema()
6363
validator = OperatorValidator(schema)
64+
validator.allow_unknown = True
6465
result = validator.validate(obj_dict)
6566

6667
if not result:

ads/opctl/operator/lowcode/forecast/schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ spec:
227227
required: true
228228
schema:
229229
type: string
230+
default: ["Column1"]
230231

231232
horizon:
232233
required: true

docs/source/user_guide/cli/opctl/configure.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This will prompt you to setup default ADS CLI configurations for each OCI profil
2828
[OCI]
2929
oci_config = ~/.oci/config
3030
oci_profile = ANOTHERPROF
31+
auth = api_key # security_token, instance_principal, resource_principal
3132
3233
[CONDA]
3334
conda_pack_folder = </local/path/for/saving/condapack>
@@ -137,7 +138,7 @@ To generate starter specification run -
137138
138139
ads opctl init --help
139140
140-
The resource type is a mandatory attribute that needs to be provided. Currently supported resource types - `dataflow`, `deployment`, `job` and `pipeline`.
141+
The resource type is a mandatory attribute that needs to be provided. Currently supported resource types - ``dataflow``, ``deployment``, ``job`` and ``pipeline``.
141142
For instance to generate starter specification for the Data Science job, run -
142143

143144
.. code-block::
@@ -149,10 +150,10 @@ The resulting YAML will be printed in the console. By default the ``python`` run
149150

150151
**Supported runtimes**
151152

152-
- For a ``job`` - `container`, `gitPython`, `notebook`, `python` and `script`.
153-
- For a ``pipeline`` - `container`, `gitPython`, `notebook`, `python` and `script`.
154-
- For a ``dataflow`` - `dataFlow` and `dataFlowNotebook`.
155-
- For a ``deployment`` - `conda` and `container`.
153+
- For a ``job`` - ``container``, ``gitPython``, ``notebook``, ``python`` and ``script``.
154+
- For a ``pipeline`` - ``container``, ``gitPython``, ``notebook``, ``python`` and ``script``.
155+
- For a ``dataflow`` - ``dataFlow`` and ``dataFlowNotebook``.
156+
- For a ``deployment`` - ``conda`` and ``container``.
156157

157158

158159
If you want to specify a particular runtime use -
@@ -166,4 +167,3 @@ Use the ``--output`` attribute to save the result in a YAML file.
166167
.. code-block::
167168
168169
ads opctl init job --runtime-type container --output job_with_container_runtime.yaml
169-
22.8 KB
Loading

docs/source/user_guide/operators/common/run.rst

Lines changed: 133 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,49 @@ The first step is to generate starter kit configurations that simplify the execu
1919

2020
.. code-block:: bash
2121
22-
ads operator init --type <operator-type>
22+
ads operator init --help
23+
24+
.. figure:: figures/operator_init.png
25+
:align: center
26+
27+
.. admonition:: Important
28+
:class: warning
29+
30+
If the ``--merge-config`` flag is set to ``true``, the ``<operator-type>.yaml`` file will be merged with the backend configuration which contains pre-populated infrastructure and runtime sections. You don't need to provide a backend information separately in this case.
31+
32+
.. code-block:: bash
33+
34+
ads operator run -f <operator-type>.yaml
35+
36+
Alternatively ``ads opctl run`` command can be used:
37+
38+
.. code-block:: bash
39+
40+
ads opctl run -f <operator-type>.yaml
41+
42+
The operator will be run in chosen environment without requiring additional modifications.
43+
44+
45+
Different Ways To Run Operator
46+
------------------------------
47+
48+
To operator can be run in two different ways:
49+
50+
.. code-block:: bash
51+
52+
ads operator run -f <operator-config>.yaml
53+
54+
Or alternatively:
55+
56+
.. code-block:: bash
57+
58+
ads opctl run -f <operator-config>.yaml
59+
60+
Despite the presented above commands look equivalent, the ``ads operator run`` command is more flexible.
61+
Here the few restrictions when running the operator within the ``ads opctl run`` command:
62+
63+
- The ``<operator-config>.yaml`` file must contain all the necessary information for running the operator. This means that the ``<operator-config>.yaml`` file must contain the ``runtime`` section describing the backend configuration for the operator.
64+
- If the ``<operator-config>.yaml`` file not contains the ``runtime`` section, then the ``ads opctl run`` command can be used in restricted mode with ``-b`` option. This option allows you to specify the backend to run the operator on. The ``-b`` option can be used with the following backends: ``local``, ``dataflow``, ``job``. However you will not be able to use the ``-b`` option with the local ``container`` backend and Data Science Jobs ``container`` backend.
2365

2466

2567
Run Operator Locally
@@ -34,20 +76,26 @@ To run the operator locally, follow these steps:
3476

3577
1. Create and activate a new conda environment named ``<operator-type>``.
3678
2. Install all the required libraries listed in the ``environment.yaml`` file generated by the ``ads operator init --type <operator-type>`` command.
37-
3. Review the ``<operator-type>.yaml`` file generated by the ``ads operator init`` command and make necessary adjustments to input and output file locations.
79+
3. Review the ``<operator-type>.yaml`` file generated by the ``ads operator init`` command and make necessary adjustments to input and output file locations. Notice that the ``<operator-type>.yaml`` will not be generated if the ``--merge-config`` flag is set to ``true``.
3880
4. Verify the operator's configuration using the following command:
3981

4082
.. code-block:: bash
4183
42-
ads operator verify -f <operator-type>.yaml
84+
ads operator verify -f <operator-config>.yaml
4385
4486
5. To run the operator within the ``<operator-type>`` conda environment, use this command:
4587

4688
.. code-block:: bash
4789
4890
ads operator run -f <operator-type>.yaml -b local
4991
50-
The operator will be run in your local environment without requiring additional modifications.
92+
The alternative way to run the operator would be to use the ``ads opctl run`` command:
93+
94+
.. code-block:: bash
95+
96+
ads opctl run -f <operator-type>.yaml -b local
97+
98+
See the `Different Ways To Run Operator <#different-ways-to-run-operator>`_ section for more details.
5199

52100
Within Container
53101
~~~~~~~~~~~~~~~~
@@ -83,6 +131,21 @@ Following is the YAML schema for validating the runtime YAML using `Cerberus <ht
83131
84132
ads operator run -f <operator-type>.yaml -b backend_operator_local_container_config.yaml
85133
134+
Or within a short command:
135+
136+
.. code-block:: bash
137+
138+
ads operator run -f <operator-type>.yaml -b local.container
139+
140+
141+
The alternative way to run the operator would be to use the ``ads opctl run`` command. However in this case the runtime information needs to be merged within operator's config. See the `Different Ways To Run Operator <#different-ways-to-run-operator>`_ section for more details.
142+
143+
.. code-block:: bash
144+
145+
ads opctl run -f <operator-type>.yaml
146+
147+
If the backend runtime information is not merged within operator's config, then there is no way to run the operator within the ``ads opctl run`` command using container runtime. The ``ads operator run`` command should be used instead.
148+
86149

87150
Run Operator In Data Science Job
88151
--------------------------------
@@ -122,22 +185,40 @@ To publish ``<operator-type>:<operator-version>`` to OCR, use this command:
122185
123186
After publishing the container to OCR, you can use it within Data Science jobs service. Check the ``backend_job_container_config.yaml`` configuration file built during initializing the starter configs for the operator. It should contain pre-populated infrastructure and runtime sections. The runtime section should have an image property, like ``image: iad.ocir.io/<tenancy>/<operator-type>:<operator-version>``.
124187

125-
1. Adjust the ``<operator-type>.yaml`` configuration with the proper input/output folders. When running operator in a Data Science job, it won't have access to local folders, so input data and output folders should be placed in the Object Storage bucket. Open the ``<operator-type>.yaml`` and adjust the data path fields.
188+
3. Adjust the ``<operator-type>.yaml`` configuration with the proper input/output folders. When running operator in a Data Science job, it won't have access to local folders, so input data and output folders should be placed in the Object Storage bucket. Open the ``<operator-type>.yaml`` and adjust the data path fields.
126189

127-
2. Run the operator on the Data Science jobs using this command:
190+
4. Run the operator on the Data Science jobs using this command:
128191

129192
.. code-block:: bash
130193
131194
ads operator run -f <operator-type>.yaml -b backend_job_container_config.yaml
132195
133-
You can run the operator within the ``--dry-run`` attribute to check the final configs that will be used to run the operator on the service.
196+
Or within a short command:
197+
198+
.. code-block:: bash
199+
200+
ads operator run -f <operator-type>.yaml -b job.container
201+
202+
In this case the backend config will be built on the fly.
203+
However the recommended way would be to use explicit configurations for both operator and backend.
204+
205+
The alternative way to run the operator would be to use the ``ads opctl run`` command. However in this case the runtime information needs to be merged within operator's config. See the `Different Ways To Run Operator <#different-ways-to-run-operator>`_ section for more details.
206+
207+
.. code-block:: bash
208+
209+
ads opctl run -f <operator-type>.yaml
210+
211+
If the backend runtime information is not merged within operator's config, then there is no way to run the operator within the ``ads opctl run`` command using container runtime. The ``ads operator run`` command should be used instead.
212+
213+
You can run the operator within the ``--dry-run`` attribute to check the final configs that will be used to run the operator on the service. This command will not run the operator, but will print the final configs that will be used to run the operator on the service.
134214

135215
Running the operator will return a command to help you monitor the job's logs:
136216

137217
.. code-block:: bash
138218
139219
ads opctl watch <OCID>
140220
221+
141222
Run With Conda Environment
142223
~~~~~~~~~~~~~~~~~~~~~~~~~~
143224

@@ -173,7 +254,28 @@ For more details on configuring the CLI, refer to the :doc:`Explore & Configure
173254

174255
.. code-block:: bash
175256
176-
ads operator run -f <operator-type>.yaml --backend-config backend_job_python_config.yaml
257+
ads operator run -f <operator-type>.yaml -b backend_job_python_config.yaml
258+
259+
Or within a short command:
260+
261+
.. code-block:: bash
262+
263+
ads operator run -f <operator-type>.yaml -b job
264+
265+
In this case the backend config will be built on the fly.
266+
However the recommended way would be to use explicit configurations for both operator and backend.
267+
268+
The alternative way to run the operator would be to use the ``ads opctl run`` command. However in this case the runtime information needs to be merged within operator's config. See the `Different Ways To Run Operator <#different-ways-to-run-operator>`_ section for more details.
269+
270+
.. code-block:: bash
271+
272+
ads opctl run -f <operator-type>.yaml
273+
274+
Or if the backend runtime information is not merged within operator's config:
275+
276+
.. code-block:: bash
277+
278+
ads opctl run -f <operator-type>.yaml -b job
177279
178280
6. Monitor the logs using the ``ads opctl watch`` command::
179281

@@ -217,7 +319,29 @@ After publishing the conda environment to Object Storage, you can use it within
217319

218320
.. code-block:: bash
219321
220-
ads operator run -f <operator-type>.yaml --backend-config backend_dataflow_dataflow_config.yaml
322+
ads operator run -f <operator-type>.yaml -b backend_dataflow_dataflow_config.yaml
323+
324+
Or within a short command:
325+
326+
.. code-block:: bash
327+
328+
ads operator run -f <operator-type>.yaml -b dataflow
329+
330+
In this case the backend config will be built on the fly.
331+
However the recommended way would be to use explicit configurations for both operator and backend.
332+
333+
The alternative way to run the operator would be to use the ``ads opctl run`` command. However in this case the runtime information needs to be merged within operator's config. See the `Different Ways To Run Operator <#different-ways-to-run-operator>`_ section for more details.
334+
335+
.. code-block:: bash
336+
337+
ads opctl run -f <operator-type>.yaml
338+
339+
Or if the backend runtime information is not merged within operator's config:
340+
341+
.. code-block:: bash
342+
343+
ads opctl run -f <operator-type>.yaml -b dataflow
344+
221345
222346
5. Monitor the logs using the ``ads opctl watch`` command::
223347

0 commit comments

Comments
 (0)