diff --git a/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/elyra-airflow-catalog.json b/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/elyra-airflow-catalog.json index 9c5cae2..b5a54c7 100644 --- a/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/elyra-airflow-catalog.json +++ b/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/elyra-airflow-catalog.json @@ -41,12 +41,12 @@ "type": "string", "default": "Example pipeline components for Apache Airflow" }, - "runtime": { - "title": "Runtime", + "runtime_type": { + "title": "Runtime type", "description": "The runtime for which to load the example components.", "type": "string", - "enum": ["airflow"], - "default": "airflow", + "enum": ["APACHE_AIRFLOW"], + "default": "APACHE_AIRFLOW", "uihints": { "field_type": "dropdown" } @@ -65,7 +65,7 @@ } } }, - "required": ["runtime"] + "required": ["runtime_type"] } }, "required": ["schema_name", "display_name", "version", "metadata"] diff --git a/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/examples_connector.py b/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/examples_connector.py index 01c75a5..ebc9140 100644 --- a/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/examples_connector.py +++ b/component-catalog-connectors/airflow-example-components-connector/airflow_examples_connector/examples_connector.py @@ -22,6 +22,7 @@ from elyra.pipeline.catalog_connector import ComponentCatalogConnector +from elyra.pipeline.runtime_type import RuntimeProcessorType class ExamplesCatalogConnector(ComponentCatalogConnector): @@ -36,25 +37,28 @@ def get_catalog_entries(self, catalog_metadata: Dict[str, Any]) -> List[Dict[str """ component_list = [] - runtime_type = catalog_metadata.get('runtime') + runtime_type_name = catalog_metadata.get('runtime_type') + runtime_type = RuntimeProcessorType.get_instance_by_name(runtime_type_name) + # The runtime type's user-friendly display name + runtime_type_display_name = runtime_type.value - if runtime_type != 'airflow': - self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type}\': ' - 'Only Apache Airflow is supported.') + if runtime_type != RuntimeProcessorType.APACHE_AIRFLOW: + self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type_display_name}\': ' + f'Only \'{RuntimeProcessorType.APACHE_AIRFLOW.value}\' is supported.') # return empty component specification list return component_list try: root_dir = Path(__file__).parent / 'resources' - self.log.debug(f'Retrieving component list for runtime type \'{runtime_type}\' from ' - f'{root_dir}') + self.log.debug(f'Retrieving component list for runtime type \'{runtime_type_display_name}\' from ' + f'{root_dir}') pattern = '**/*.py' self.log.debug(f'Component file pattern: {pattern}') for file in root_dir.glob(pattern): component_list.append({'component-id': str(file)[len(str(root_dir)) + 1:]}) self.log.debug(f'Component list: {component_list}') except Exception as ex: - self.log.error(f"Error retrieving component list for runtime type '{runtime_type}'" + self.log.error(f"Error retrieving component list for runtime type '{runtime_type_display_name}'" f" from {root_dir}: {ex}") return component_list @@ -79,15 +83,20 @@ def read_catalog_entry(self, 'A component id must be provided.') return None - runtime_type = catalog_metadata.get('runtime') - if runtime_type != 'airflow': - self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type}\': ' - 'Only Apache Airflow is supported.') - return None + runtime_type_name = catalog_metadata.get('runtime_type') + runtime_type = RuntimeProcessorType.get_instance_by_name(runtime_type_name) + # The runtime type's user-friendly display name + runtime_type_display_name = runtime_type.value + + if runtime_type != RuntimeProcessorType.APACHE_AIRFLOW: + self.log.error(f'Cannot retrieve component for runtime type \'{runtime_type_name}\': ' + f'Only \'{RuntimeProcessorType.APACHE_AIRFLOW.value}\' is supported.') try: # load component from resources directory root_dir = Path(__file__).parent / 'resources' + self.log.debug(f'Retrieving component of runtime type \'{runtime_type_display_name}\' from ' + f'{root_dir}') with open(root_dir / component_id, 'r') as fp: return fp.read() except Exception as e: diff --git a/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/elyra-kfp-catalog.json b/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/elyra-kfp-catalog.json index a97b0cd..53d3f6b 100644 --- a/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/elyra-kfp-catalog.json +++ b/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/elyra-kfp-catalog.json @@ -41,12 +41,12 @@ "type": "string", "default": "Example pipeline components for Kubeflow Pipelines" }, - "runtime": { - "title": "Runtime", + "runtime_type": { + "title": "Runtime type", "description": "The runtime for which to load the example components.", "type": "string", - "enum": ["kfp"], - "default": "kfp", + "enum": ["KUBEFLOW_PIPELINES"], + "default": "KUBEFLOW_PIPELINES", "uihints": { "field_type": "dropdown" } @@ -65,7 +65,7 @@ } } }, - "required": ["runtime"] + "required": ["runtime_type"] } }, "required": ["schema_name", "display_name", "version", "metadata"] diff --git a/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/examples_connector.py b/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/examples_connector.py index d53ee85..cefe1ab 100644 --- a/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/examples_connector.py +++ b/component-catalog-connectors/kfp-example-components-connector/kfp_examples_connector/examples_connector.py @@ -20,8 +20,8 @@ from typing import List from typing import Optional - from elyra.pipeline.catalog_connector import ComponentCatalogConnector +from elyra.pipeline.runtime_type import RuntimeProcessorType class ExamplesCatalogConnector(ComponentCatalogConnector): @@ -36,25 +36,28 @@ def get_catalog_entries(self, catalog_metadata: Dict[str, Any]) -> List[Dict[str """ component_list = [] - runtime_type = catalog_metadata.get('runtime') + runtime_type_name = catalog_metadata.get('runtime_type') + runtime_type = RuntimeProcessorType.get_instance_by_name(runtime_type_name) + # The runtime type's user-friendly display name + runtime_type_display_name = runtime_type.value - if runtime_type != 'kfp': - self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type}\': ' - 'Only Kubeflow Pipelines is supported.') + if runtime_type != RuntimeProcessorType.KUBEFLOW_PIPELINES: + self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type_display_name}\': ' + f'Only \'{RuntimeProcessorType.KUBEFLOW_PIPELINES.value}\' is supported.') # return empty component specification list return component_list try: root_dir = Path(__file__).parent / 'resources' - self.log.debug(f'Retrieving component list for runtime type \'{runtime_type}\' from ' - f'{root_dir}') + self.log.debug(f'Retrieving component list for runtime type \'{runtime_type_display_name}\' from ' + f'{root_dir}') pattern = '**/*.yaml' self.log.debug(f'Component file pattern: {pattern}') for file in root_dir.glob(pattern): component_list.append({'component-id': str(file)[len(str(root_dir)) + 1:]}) self.log.debug(f'Component list: {component_list}') except Exception as ex: - self.log.error(f"Error retrieving component list for runtime type '{runtime_type}'" + self.log.error(f"Error retrieving component list for runtime type '{runtime_type_display_name}'" f" from {root_dir}: {ex}") return component_list @@ -79,15 +82,20 @@ def read_catalog_entry(self, 'A component id must be provided.') return None - runtime_type = catalog_metadata.get('runtime') - if runtime_type != 'kfp': - self.log.error(f'Cannot retrieve component list for runtime type \'{runtime_type}\': ' - 'Only Kubeflow Pipelines is supported.') - return None + runtime_type_name = catalog_metadata.get('runtime_type') + runtime_type = RuntimeProcessorType.get_instance_by_name(runtime_type_name) + # The runtime type's user-friendly display name + runtime_type_display_name = runtime_type.value + + if runtime_type != RuntimeProcessorType.KUBEFLOW_PIPELINES: + self.log.error(f'Cannot retrieve component for runtime type \'{runtime_type_display_name}\': ' + f'Only \'{RuntimeProcessorType.KUBEFLOW_PIPELINES.value}\' is supported.') try: # load component from resources directory root_dir = Path(__file__).parent / 'resources' + self.log.debug(f'Retrieving component of runtime type \'{runtime_type_display_name}\' from ' + f'{root_dir}') with open(root_dir / component_id, 'r') as fp: return fp.read() except Exception as e: