Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make multi-valued input fields more user-friendly #2927

Merged
merged 186 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
1999bf0
Add initial support for rjsf in pipeline properties
Jun 9, 2022
1ece8c2
Move back string arrays to original format
Jun 9, 2022
78a2801
Rough first pass at node properties
Jun 27, 2022
5007e29
Update schema to reflect new uihints
Jun 28, 2022
5b8671e
Add initial canvas properties conversion
Jun 29, 2022
697668a
Minor template fixes
kiersten-stokes Jun 30, 2022
9fa3468
Update field values to be consistent with json schema
Jul 5, 2022
fb06312
Fix parsing error
Jul 5, 2022
d7df9a1
Update field values and remove unnecessary template values
Jul 6, 2022
520066d
Allow None for control_id
kiersten-stokes Jul 7, 2022
e9dc151
Simplify and re-factor backend component property rendering
kiersten-stokes Jul 8, 2022
d43b56b
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Jul 19, 2022
bf251df
Add mounted_volumes to custom component properties
kiersten-stokes Jul 19, 2022
5eb0d13
Add dummy type for outputs
kiersten-stokes Jul 21, 2022
178f2b3
Add support for remembering the widget in oneOf field
Jul 26, 2022
4295887
Use title in options list
Jul 26, 2022
c5bda72
Add outputpath flag
Jul 28, 2022
7fcd741
Remove max values for generic components
kiersten-stokes Jul 28, 2022
3e18a50
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Jul 28, 2022
424d17e
Fix inputpath bug
Jul 29, 2022
5a53bbb
Merge branch 'pipeline-rjsf' of github.com:marthacryan/elyra into pip…
Jul 29, 2022
2518cc1
Remove print statement
Jul 29, 2022
4a72a6e
Clean up css
Jul 29, 2022
9eec6d1
Clean up css for file button
Jul 29, 2022
33e51d1
Fix parsing error
Aug 1, 2022
7ecb663
Add component source
Aug 1, 2022
8900203
Add input / output categories for kfp
Aug 1, 2022
09a742e
Add extra header / description
Aug 1, 2022
5f1df4c
Fix adjustable sizing
Aug 3, 2022
2a2d947
Add error indicator
Aug 4, 2022
da03c0f
Clean up error style
Aug 5, 2022
bffc510
Make integers more compact
Aug 8, 2022
a3354c6
Add style for pipeline defaults in arrays
Aug 10, 2022
98ebcbf
Add sandbox for testing
Aug 11, 2022
cc82d5c
Re-add allow_no_options param flag
kiersten-stokes Aug 11, 2022
3950708
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Aug 11, 2022
6ad0ef0
Add descriptions for allow_no_option param
kiersten-stokes Aug 11, 2022
8c6e09a
Update templates after merge
kiersten-stokes Aug 11, 2022
f863ebf
Fix indentations after merge
kiersten-stokes Aug 11, 2022
c7d9f75
Fix lint
Aug 11, 2022
ebeb71a
Add new code sandbox
Aug 11, 2022
25a898d
Add default values
kiersten-stokes Aug 12, 2022
3a9fdce
Coerce default values as appropriate
kiersten-stokes Aug 12, 2022
97102c6
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Aug 12, 2022
4b1c6d7
Make first pass at KFP processing
kiersten-stokes Aug 12, 2022
98945ad
Add initial file processing logic for KFP
kiersten-stokes Aug 12, 2022
c1ea17e
Make first pass at Airflow processing
kiersten-stokes Aug 12, 2022
fda97eb
Make first pass at updating server tests
kiersten-stokes Aug 12, 2022
a184c4d
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Aug 12, 2022
9a4f9e2
Update headers and placeholders for pipeline properties
kiersten-stokes Aug 15, 2022
223a12f
Add description style for custom components
Aug 15, 2022
77b1a37
Update processing logic in anticipation of pipeline changes
kiersten-stokes Aug 15, 2022
4f850b5
Add empty title for boolean properties to avoid placeholder
kiersten-stokes Aug 15, 2022
f7b721b
Remove extraneous function arg
kiersten-stokes Aug 15, 2022
84ee95e
Update docstring
kiersten-stokes Aug 15, 2022
115aee9
Fix relative paths in oneofs
Aug 15, 2022
88feeb9
Merge branch 'pipeline-rjsf' of github.com:marthacryan/elyra into pip…
Aug 15, 2022
4c4a1c9
fix airflow support
ajbozarth Aug 15, 2022
ebd01b3
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Aug 16, 2022
703c74a
Clean up TODOs
kiersten-stokes Aug 16, 2022
e5b8b1e
Move component_source out of component_parameters stanza
kiersten-stokes Aug 16, 2022
b6f342e
Fix missing comma in canvas template
kiersten-stokes Aug 16, 2022
21d2b08
Add condition to property propagation
kiersten-stokes Aug 16, 2022
4da8264
Update inputpath in canvas properties
kiersten-stokes Aug 17, 2022
fdf00e1
More changes to streamline data classes
kiersten-stokes Aug 18, 2022
62e5b7a
Add input and output descriptions to canvas properties
kiersten-stokes Aug 18, 2022
abc0fe0
Update how instances are created
kiersten-stokes Aug 18, 2022
bc33086
Remove component description as a property
kiersten-stokes Aug 18, 2022
be06091
Fix duplication error with properties
kiersten-stokes Aug 18, 2022
20cd107
Add test case for latest commit
kiersten-stokes Aug 18, 2022
901e35f
Make first pass at adding processing logic to properties
kiersten-stokes Aug 23, 2022
4be6e24
Add subclasses to certain properties
kiersten-stokes Aug 23, 2022
aa90741
Move ComponentParameter class to new file
kiersten-stokes Aug 24, 2022
842dc4f
Small function signature changes
kiersten-stokes Aug 24, 2022
cbc1a2d
Change runtime-specific classmethods to methods
kiersten-stokes Aug 25, 2022
afdecba
Rename properties and move loop logic to base class
kiersten-stokes Aug 25, 2022
296a9e3
Merge branch 'main' into pipeline-rjsf
kiersten-stokes Aug 29, 2022
7299866
add migration and fix validation
ajbozarth Aug 30, 2022
0e76f1d
Fix refresh button
Aug 30, 2022
cc14d6a
Migrate select test pipelines
kiersten-stokes Aug 31, 2022
c9521d9
Add missing commas to new pipeline files
kiersten-stokes Aug 31, 2022
9665257
Validate all inputpath types instead of those for only req'd properties
kiersten-stokes Aug 31, 2022
59ca344
update codesandbox to grab migration fix
ajbozarth Sep 1, 2022
ad44221
Update remaining test resources
kiersten-stokes Sep 1, 2022
32f9c17
Merge branch 'pipeline-rjsf' into rjsf-additions
kiersten-stokes Sep 1, 2022
9cc8ac8
Add new disallow_cached_output property
kiersten-stokes Sep 1, 2022
452a23b
Merge branch 'main' into pipeline-rjsf
ajbozarth Sep 1, 2022
c22228b
Separate Elyra-owned properties from parsed property validation
kiersten-stokes Sep 2, 2022
4f2e110
Merge branch 'pipeline-rjsf' of https://github.com/marthacryan/elyra …
ajbozarth Sep 2, 2022
14a086b
Update tests: all passing
ajbozarth Sep 2, 2022
ca15bb8
update failing integration test
ajbozarth Sep 2, 2022
ecb49d6
Add defaults to templates
kiersten-stokes Sep 2, 2022
8cc803e
fix snapshots
ajbozarth Sep 2, 2022
5e70ec2
Update pipeline-editor link
Sep 6, 2022
870fccc
Merge with branch
Sep 6, 2022
10d2f43
Remove all null values from the pipeline
Sep 6, 2022
41d3663
Remove extra category
Sep 6, 2022
cd85fc8
Updates to css
Sep 6, 2022
93f1196
Remove null pipeline defaults in arrays
Sep 8, 2022
415c14b
List file dependencies in describe CLI command
kiersten-stokes Sep 8, 2022
287db2f
Adjust file-based input for expected parameter type
kiersten-stokes Sep 8, 2022
b39e532
Merge branch 'pipeline-rjsf' into rjsf-additions
kiersten-stokes Sep 8, 2022
a446354
Add defaults to list property items
kiersten-stokes Sep 8, 2022
6c1ea58
Fix lint
kiersten-stokes Sep 8, 2022
d2d53c6
Add defaults to arrays to fix required errors
Sep 8, 2022
14720d8
Update link for pipeline editor changes
Sep 8, 2022
b9b2bdb
Adjust certain tests to use file-based input
kiersten-stokes Sep 8, 2022
1207575
Fix removing null values in arrays
Sep 8, 2022
899fda6
Merge branch 'pipeline-rjsf' of github.com:marthacryan/elyra into pip…
Sep 8, 2022
213a02e
Fix import statement order
kiersten-stokes Sep 9, 2022
b6c2fc1
Fix lint
Sep 9, 2022
cf7cade
Merge branch 'pipeline-rjsf' of github.com:marthacryan/elyra into pip…
Sep 9, 2022
2f5c6d9
Update codesandbox link
Sep 9, 2022
d9e3935
Update link
Sep 12, 2022
37ae74b
Fix validation for non-required file-type properties
kiersten-stokes Sep 13, 2022
2934536
Validate required file types do not have empty string as value
kiersten-stokes Sep 13, 2022
da94ec4
Merge branch 'pipeline-rjsf' into rjsf-additions
kiersten-stokes Sep 13, 2022
11add8f
Move to user-friendly input schema
kiersten-stokes Sep 13, 2022
6e94dc3
Do not render cos secret for custom ops
kiersten-stokes Sep 13, 2022
fbe6b0e
Merge branch 'main' into property-refactor
kiersten-stokes Sep 14, 2022
36cb29f
Bring custom component json render in line with latest
kiersten-stokes Sep 14, 2022
40583a7
Fix disallow_cached_output property rendering
kiersten-stokes Sep 14, 2022
e5d2dad
Remove unnecessary code blocks
kiersten-stokes Sep 14, 2022
0e9bb99
Remove to_str method in favor of dict representation
kiersten-stokes Sep 15, 2022
4ffcd12
Update utilities for env var processing
kiersten-stokes Sep 15, 2022
3ce5f89
Update cli test resources and other test utils
kiersten-stokes Sep 15, 2022
b1fa0ca
Add node defaults for object arrays
Sep 15, 2022
d80bd90
Merge branch 'property-refactor' of github.com:kiersten-stokes/elyra …
Sep 15, 2022
a1aa8c1
Add ui placeholders for individual fields
kiersten-stokes Sep 15, 2022
47bd756
Merge branch 'property-refactor' of github.com:kiersten-stokes/elyra …
kiersten-stokes Sep 15, 2022
e87e326
Update additional env-related tests
kiersten-stokes Sep 15, 2022
7a423a0
Fix lint
kiersten-stokes Sep 15, 2022
fb78598
Begin runtime processing re-factor
kiersten-stokes Sep 16, 2022
4b3812d
Finish up runtime processing re-factor
kiersten-stokes Sep 19, 2022
e8952b5
Update Airflow component parser to accept binary type hints
kiersten-stokes Sep 19, 2022
ee256b6
Address feedback received offline
kiersten-stokes Sep 19, 2022
4f76c07
Test for required during Elyra-owned property validation
kiersten-stokes Sep 20, 2022
267a440
Update select tests
kiersten-stokes Sep 20, 2022
809da5f
Address feedback in PR comments
kiersten-stokes Sep 20, 2022
c64c70f
Remove runtime image as subclass of ElyraProperty
kiersten-stokes Sep 20, 2022
51c7aeb
Update tests after removal of RuntimeImage
kiersten-stokes Sep 20, 2022
286e98b
Fix remaining backend tests
kiersten-stokes Sep 20, 2022
9d48ec8
Require env var key but not value during validation
kiersten-stokes Sep 20, 2022
01b3b7c
Add type hints to add_instance functions
kiersten-stokes Sep 20, 2022
d96cb11
Bug fixes:
ptitzler Sep 21, 2022
1d2875e
Update pipelines documentation topic
ptitzler Sep 21, 2022
2b35841
Use "disable node caching" instead of "disallow cached output" in con…
ptitzler Sep 21, 2022
f1759da
Update link
Sep 21, 2022
5bc3286
Update automatic env var population
Sep 21, 2022
87f4ad8
Remove empty objects from arrays
Sep 21, 2022
2b4d669
update link
Sep 21, 2022
b9bd9d4
Update integration tests for new UI
Sep 21, 2022
597f3f1
Update snapshot
Sep 21, 2022
97c151b
Update snapshots and don't remove empty strings
Sep 21, 2022
e97c506
Remove empty string in object arrays
Sep 21, 2022
ea6dfb6
Add back in required fields
Sep 21, 2022
9ea44b5
add migration
ajbozarth Sep 22, 2022
270e8ff
update link
Sep 22, 2022
73c60ba
Merge
Sep 22, 2022
e479e58
Fix failing kubernetes secrets test
ptitzler Sep 22, 2022
b510645
Fix toleration validation
ptitzler Sep 22, 2022
f6592bb
Update validation and tests for secrets, volumes, and annotations
ptitzler Sep 22, 2022
ed695f8
Fix volume bug and invalid-only env vars bug
kiersten-stokes Sep 22, 2022
edd07ea
Remove __slots__ in favor of datastructure
kiersten-stokes Sep 22, 2022
d5e23b3
Fix Falsy checks in validation
kiersten-stokes Sep 22, 2022
3b79b1d
Check for instance type in pipeline app workaround
kiersten-stokes Sep 23, 2022
7fcc62a
Check instance type before add_to_execution_object
kiersten-stokes Sep 23, 2022
cc958a8
address front end review
ajbozarth Sep 23, 2022
01d1ffe
Move list property get_schema logic to prepare for new props
kiersten-stokes Sep 23, 2022
250d765
Merge branch 'property-refactor' of github.com:kiersten-stokes/elyra …
kiersten-stokes Sep 23, 2022
c7912ab
Fix lint
kiersten-stokes Sep 23, 2022
f40cfe0
Ensure Elyra properties are removed from operation component params
kiersten-stokes Sep 23, 2022
4ebc60b
Revert generic properties template and adjust handler test
kiersten-stokes Sep 26, 2022
16b0012
Fix lint
kiersten-stokes Sep 26, 2022
ef1afd6
Add headers to generic component template
kiersten-stokes Sep 26, 2022
291b6ba
Update generic property fetch test
kiersten-stokes Sep 26, 2022
cdeb193
Revert how secrets are rendered in Airflow for generics
kiersten-stokes Sep 26, 2022
c19d66d
Streamline rendering of secrets for Airflow
kiersten-stokes Sep 26, 2022
105a33e
Fix typo
kiersten-stokes Sep 26, 2022
d6f76d3
Split properties into component vs Elyra during pipeline parse
kiersten-stokes Sep 26, 2022
1929c9f
Fix incorrect import statements
kiersten-stokes Sep 26, 2022
84b6a7c
Separate processing of some properties for generic Airflow nodes
kiersten-stokes Sep 27, 2022
318fe8c
Fix if/elif bug in env var validation
kiersten-stokes Sep 27, 2022
23e48ab
Make Airflow tolerations a no-op for generics
kiersten-stokes Sep 27, 2022
0e76982
Re-add toleration effect rendering for generics
kiersten-stokes Sep 27, 2022
1697d82
update to use pipeline-editor rc release
ajbozarth Sep 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions docs/source/user_guide/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Each pipeline node is configured using properties. Default node properties are a

**Default properties that apply only to custom nodes**

- [Disallow cached output](#disallow-cached-output)
- [Disable node caching](#disable-node-caching)

#### Adding nodes

Expand Down Expand Up @@ -163,7 +163,7 @@ Nodes that are implemented using [custom components](pipeline-components.html#cu
- [Data volumes](#data-volumes)
- [Kubernetes tolerations](#kubernetes-tolerations)
- [Kubernetes pod annotations](#kubernetes-pod-annotations)
- [Disallow cached output](#disallow-cached-output)
- [Disable node caching](#disable-node-caching)

#### Defining dependencies between nodes

Expand Down Expand Up @@ -203,19 +203,26 @@ The following alphabetically sorted list identifies the node properties that are

##### Data volumes
- A list of [Persistent Volume Claims](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) (PVC) to be mounted into the container that executes the component.
- Format: `/mnt/path=existing-pvc-name`. Entries that are empty (`/mnt/path=`) or malformed are ignored. Entries with a PVC name considered to be an [invalid Kubernetes resource name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names) will raise a validation error after pipeline submission or export.
- The referenced PVCs must exist in the Kubernetes namespace where the pipeline nodes are executed.
- Format:
- _Mount path_: the path where the PVC shall be mounted in the container. Example: `/mnt/datavol/`
- _Persistent volume claim name_: a valid [Kubernetes resource name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names) identifying a PVC that exists in the Kubernetes namespace where the pipeline nodes are executed. Example: `my-data-pvc`
- Data volumes are not mounted when the pipeline is executed locally.

##### Disallow cached output
##### Disable node caching
- Pipeline nodes produce output, such as files. Some runtime environments support caching of these outputs, eliminating the need to re-execute nodes, which can improve performance and reduce resource usage. If a node does not produce output in a deterministic way - that is, when given the same inputs, the generated output is different - re-using the output from previous executions might lead to unexpected results.
- Format:
- `True` node output is not cached
- `False` node output is cached
- If no behavior is specified, the runtime environment's default caching behavior is applied.
- Caching can only be disabled for pipelines that are executed on Kubeflow Pipelines.

##### Environment Variables
- This property applies only to generic components.
- A list of environment variables to be set inside in the container. Specify one variable/value pair per line, separated by `=`.
- A list of environment variables to be set inside in the container.
- Format:
- _Environment variable_: name of the variable to be set. Example: `optimize`
- _Value_: the value to be assigned to said variable. Example: `true`
- A set of default environment variables can also be set in the pipeline properties tab. If any default environment variables are set, the **Environment Variables** property in the node properties tab will include these variables and their values with a note that each is a pipeline default. Pipeline default environment variables are not editable from the node properties tab. Individual nodes can override a pipeline default value for a given variable by re-defining the variable/value pair in its own node properties.
- Example: `TOKEN=value`

##### File Dependencies
- This property applies only to generic components.
Expand All @@ -230,20 +237,28 @@ The following alphabetically sorted list identifies the node properties that are

##### Kubernetes Pod Annotations
- A list of [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#attaching-metadata-to-objects) to be attached to the pod that executes the node.
- Format: `annotation-key=annotation-value`. Entries that are empty (`annotation-key=`) are ignored. Entries with a key considered to be [invalid](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set) will raise a validation error after pipeline submission or export.
- Format:
- _Key_: a [valid Kubernetes annotation key](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set). Example: `project`
- _Value_: value to be assigned to said annotation key. Example: `abandoned basket analysis`
- Annotations are ignored when the pipeline is executed locally.
- Example: `project=abandoned basket analysis`

##### Kubernetes Secrets
- A list of [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) to be accessed as environment variables during Jupyter notebook or script execution. Format: `ENV_VAR=secret-name:secret-key`. Entries that are empty (`ENV_VAR=`) or malformed are ignored. Entries with a secret name considered to be an [invalid Kubernetes resource name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names) or with [an invalid secret key](https://kubernetes.io/docs/concepts/configuration/secret/#restriction-names-data) will raise a validation error after pipeline submission or export. The referenced secrets must exist in the Kubernetes namespace where the generic pipeline nodes are executed.
- A list of [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) to be accessed as environment variables during Jupyter notebook or script execution.
- Format:
- _Environment variable_: name of the variable to be set. Example: `optimize`
- _Secret Name_: a valid [Kubernetes resource name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names) identifying a [secret](https://kubernetes.io/docs/concepts/configuration/secret/#restriction-names-data) that exists in the Kubernetes namespace where the pipeline nodes are executed. Example: `database-credentials`
- _Secret Key_: key that is defined in said secret. Example: `uid`
- Secrets are ignored when the pipeline is executed locally. For remote execution, if an environment variable was assigned both a static value (via the 'Environment Variables' property) and a Kubernetes secret value, the secret's value is used.
- Example: `ENV_VAR=secret-name:secret-key`

##### Kubernetes Tolerations
- A list of [Kubernetes tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) to be applied to the pod where the component is executed.
- Format: `TOL_ID=key:operator:value:effect`. Refer to [the toleration specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#toleration-v1-core) for a description of the values for `key`, `operator`, `value`, and `effect`.
- Format:
- _Key_: taint key the toleration applies to
- _Operator_: represents the key's relationship to the value. Must be `Equal` or `Exists`.
- _Value_: taint value the toleration matches to
- _Effect_: indicates the taint effect to match. If specified, must be `NoExecute`, `NoSchedule`, or `PreferNoSchedule`.
- Refer to [the toleration specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#toleration-v1-core) for a description of each property.
- Tolerations are ignored when the pipeline is executed locally.
- Example: `TOL_1=my-key:Exists::NoExecute`

##### Label
- Specify a label to replace the default node name. For generic components the default label is the file name. For custom components the default name is the component name.
Expand Down
7 changes: 6 additions & 1 deletion elyra/cli/pipeline_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from elyra.metadata.schemaspaces import Runtimes
from elyra.pipeline import pipeline_constants
from elyra.pipeline.component_catalog import ComponentCache
from elyra.pipeline.component_parameter import VolumeMount
from elyra.pipeline.kfp.kfp_authentication import AuthenticationError
from elyra.pipeline.kfp.kfp_authentication import KFPAuthenticator
from elyra.pipeline.parser import PipelineParser
Expand Down Expand Up @@ -584,7 +585,11 @@ def describe(json_option, pipeline_path):
# (... there are none today)
# volumes
for vm in node.get_component_parameter(pipeline_constants.MOUNTED_VOLUMES, []):
describe_dict["volume_dependencies"]["value"].add(vm.pvc_name)
# The below is a workaround until https://github.com/elyra-ai/elyra/issues/2919 is fixed
if not isinstance(vm, (VolumeMount, dict)):
continue
pvc_name = vm.pvc_name if isinstance(vm, VolumeMount) else vm.get("pvc_name")
describe_dict["volume_dependencies"]["value"].add(pvc_name)

if Operation.is_generic_operation(node.op):
# update stats that are specific to generic components
Expand Down
64 changes: 0 additions & 64 deletions elyra/kfp/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,10 @@
from kubernetes.client.models import V1EnvVar
from kubernetes.client.models import V1EnvVarSource
from kubernetes.client.models import V1ObjectFieldSelector
from kubernetes.client.models import V1PersistentVolumeClaimVolumeSource
from kubernetes.client.models import V1SecretKeySelector
from kubernetes.client.models import V1Toleration
from kubernetes.client.models import V1Volume
from kubernetes.client.models import V1VolumeMount

from elyra._version import __version__
from elyra.pipeline.pipeline import KubernetesAnnotation
from elyra.pipeline.pipeline import KubernetesSecret
from elyra.pipeline.pipeline import KubernetesToleration
from elyra.pipeline.pipeline import VolumeMount

"""
The ExecuteFileOp uses a python script to bootstrap the user supplied image with the required dependencies.
Expand Down Expand Up @@ -92,10 +85,6 @@ def __init__(
mem_request: Optional[str] = None,
gpu_limit: Optional[str] = None,
workflow_engine: Optional[str] = "argo",
volume_mounts: Optional[List[VolumeMount]] = None,
kubernetes_secrets: Optional[List[KubernetesSecret]] = None,
kubernetes_tolerations: Optional[List[KubernetesToleration]] = None,
kubernetes_pod_annotations: Optional[List[KubernetesAnnotation]] = None,
**kwargs,
):
"""Create a new instance of ContainerOp.
Expand All @@ -119,10 +108,6 @@ def __init__(
mem_request: memory requested for the operation (in Gi)
gpu_limit: maximum number of GPUs allowed for the operation
workflow_engine: Kubeflow workflow engine, defaults to 'argo'
volume_mounts: data volumes to be mounted
kubernetes_secrets: secrets to be made available as environment variables
kubernetes_tolerations: Kubernetes tolerations to be added to the pod
kubernetes_pod_annotations: annotations to be applied to the pod
kwargs: additional key value pairs to pass e.g. name, image, sidecars & is_exit_handler.
See Kubeflow pipelines ContainerOp definition for more parameters or how to use
https://kubeflow-pipelines.readthedocs.io/en/latest/source/kfp.dsl.html#kfp.dsl.ContainerOp
Expand All @@ -149,12 +134,6 @@ def __init__(
self.cpu_request = cpu_request
self.mem_request = mem_request
self.gpu_limit = gpu_limit
self.volume_mounts = volume_mounts # optional data volumes to be mounted to the pod
self.kubernetes_secrets = kubernetes_secrets # optional secrets to be made available as env vars
self.kubernetes_tolerations = (
kubernetes_tolerations # optional Kubernetes tolerations to be attached to the pod
)
self.kubernetes_pod_annotations = kubernetes_pod_annotations # optional annotations

argument_list = []

Expand Down Expand Up @@ -246,55 +225,12 @@ def __init__(

super().__init__(**kwargs)

# add user-specified volume mounts: the referenced PVCs must exist
# or this generic operation will fail
if self.volume_mounts:
unique_pvcs = []
for volume_mount in self.volume_mounts:
if volume_mount.pvc_name not in unique_pvcs:
self.add_volume(
V1Volume(
name=volume_mount.pvc_name,
persistent_volume_claim=V1PersistentVolumeClaimVolumeSource(
claim_name=volume_mount.pvc_name
),
)
)
unique_pvcs.append(volume_mount.pvc_name)
self.container.add_volume_mount(V1VolumeMount(mount_path=volume_mount.path, name=volume_mount.pvc_name))

# We must deal with the envs after the superclass initialization since these amend the
# container attribute that isn't available until now.
if self.pipeline_envs:
for key, value in self.pipeline_envs.items(): # Convert dict entries to format kfp needs
self.container.add_env_variable(V1EnvVar(name=key, value=value))

if self.kubernetes_secrets:
for secret in self.kubernetes_secrets: # Convert tuple entries to format kfp needs
self.container.add_env_variable(
V1EnvVar(
name=secret.env_var,
value_from=V1EnvVarSource(secret_key_ref=V1SecretKeySelector(name=secret.name, key=secret.key)),
)
)

# add user-provided tolerations
if self.kubernetes_tolerations:
for toleration in self.kubernetes_tolerations:
self.add_toleration(
V1Toleration(
effect=toleration.effect,
key=toleration.key,
operator=toleration.operator,
value=toleration.value,
)
)

# add user-provided annotations to pod
if self.kubernetes_pod_annotations:
for annotation in self.kubernetes_pod_annotations:
self.add_pod_annotation(annotation.key, annotation.value)

# If crio volume size is found then assume kubeflow pipelines environment is using CRI-o as
# its container runtime
if self.emptydir_volume_size:
Expand Down
18 changes: 16 additions & 2 deletions elyra/pipeline/airflow/component_parser_airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

from elyra.pipeline.catalog_connector import CatalogEntry
from elyra.pipeline.component import Component
from elyra.pipeline.component import ComponentParameter
from elyra.pipeline.component import ComponentParser
from elyra.pipeline.component_parameter import ComponentParameter
from elyra.pipeline.runtime_type import RuntimeProcessorType

CONTROL_ID = "OneOfControl"
Expand Down Expand Up @@ -361,14 +361,28 @@ def _get_init_arguments(self, init_function: ast.FunctionDef) -> Dict[str, Dict]
and isinstance(arg.annotation.slice.value.value, ast.Name)
):
# arg is of the form `<arg>: Optional[<multi-valued_type>]`
# e.g. `env = Optional[Dict[str, str]]` or `env = Optional[List[int]]`
# [<multi-valued_type> or `env = Optional[List[int]]`
# In Python 3.7 and lower
data_type = arg.annotation.slice.value.value.id

if isinstance(arg.annotation.value, ast.Name) and arg.annotation.value.id == "Optional":
# arg typehint includes the phrase 'Optional'
required = False

elif isinstance(arg.annotation, ast.BinOp):
if (
isinstance(arg.annotation.left, ast.Subscript)
and isinstance(arg.annotation.left.value, ast.Name)
and isinstance(arg.annotation.left.value.id, str)
):
# arg is of the form `<arg>: [<type>] | [<other_type>]`
# e.g. `env = dict[str, str] | None`
data_type = arg.annotation.left.value.id

if isinstance(arg.annotation.right, ast.Constant) and arg.annotation.right.value is None:
# arg typehint includes None, making it optional
required = False

# Insert AST-parsed (or default) values into dictionary
init_arg_dict[arg_name] = {"data_type": data_type, "default_value": default_value, "required": required}

Expand Down
Loading