Skip to content

Commit 0531265

Browse files
committed
Load processor only if library is found
1 parent b2c7e22 commit 0531265

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

elyra/metadata/schemasproviders.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
# We may not have kfp-tekton available and that's okay!
3030
TektonClient = None
3131

32+
try:
33+
from kfp import compiler # noqa
34+
except ImportError:
35+
# KFP python package is not installed
36+
compiler = None
37+
38+
try:
39+
# Check to see if Airflow package is installed, since we do not have any dependencies
40+
# on any Airflow package, we use GitHub as our canary
41+
from github import Github # noqa
42+
except ImportError:
43+
# Github package is not installed, we use GitHub as our default DAG repository
44+
Github = None
45+
3246
from elyra.metadata.schema import SchemasProvider
3347
from elyra.metadata.schemaspaces import CodeSnippets
3448
from elyra.metadata.schemaspaces import ComponentCatalogs
@@ -51,7 +65,7 @@ class ElyraSchemasProvider(SchemasProvider, metaclass=ABCMeta):
5165
schema_json = json.load(f)
5266
local_schemas.append(schema_json)
5367

54-
def __init__(self):
68+
def __init__(self, *args, **kwargs):
5569
self.log = log.get_logger()
5670
# get set of registered runtimes
5771
self._runtime_processor_names = set()
@@ -82,17 +96,17 @@ def get_schemas(self) -> List[Dict]:
8296
schemas = self.get_local_schemas_by_schemaspace(Runtimes.RUNTIMES_SCHEMASPACE_ID)
8397
for schema in schemas:
8498
if schema["name"] in self._runtime_processor_names:
85-
runtime_schemas.append(schema)
86-
if schema["name"] == "kfp":
99+
if schema["name"] == "kfp" and compiler:
87100
kfp_schema_present = True
88-
elif schema["name"] == "airflow":
101+
runtime_schemas.append(schema)
102+
elif schema["name"] == "airflow" and Github:
89103
airflow_schema_present = True
104+
runtime_schemas.append(schema)
90105
else:
91106
self.log.error(
92107
f"No entrypoint with name '{schema['name']}' was found in group "
93108
f"'elyra.pipeline.processor' to match the schema with the same name. Skipping..."
94109
)
95-
96110
if kfp_schema_present: # Update the kfp engine enum to reflect current packages...
97111
# If TektonClient package is missing, navigate to the engine property
98112
# and remove 'tekton' entry if present and return updated result.

elyra/pipeline/processor.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
from urllib3.exceptions import MaxRetryError
3636

3737
from elyra.metadata.manager import MetadataManager
38+
from elyra.metadata.schema import SchemaManager
39+
from elyra.metadata.schemaspaces import Runtimes
3840
from elyra.pipeline.component import Component
3941
from elyra.pipeline.component_catalog import ComponentCache
4042
from elyra.pipeline.pipeline import GenericOperation
@@ -57,19 +59,23 @@ def __init__(self, **kwargs):
5759
self.root_dir = get_expanded_path(kwargs.get("root_dir"))
5860
# Register all known processors based on entrypoint configuration
5961
for processor in entrypoints.get_group_all("elyra.pipeline.processors"):
60-
try:
61-
# instantiate an actual instance of the processor
62-
processor_instance = processor.load()(self.root_dir, parent=kwargs.get("parent")) # Load an instance
63-
self.log.info(
64-
f"Registering {processor.name} processor " f'"{processor.module_name}.{processor.object_name}"...'
65-
)
66-
self.add_processor(processor_instance)
67-
except Exception as err:
68-
# log and ignore initialization errors
69-
self.log.error(
70-
f"Error registering {processor.name} processor "
71-
f'"{processor.module_name}.{processor.object_name}" - {err}'
72-
)
62+
if processor.name in SchemaManager.instance().get_schemasproviders(Runtimes.RUNTIMES_SCHEMASPACE_ID):
63+
try:
64+
# instantiate an actual instance of the processor
65+
processor_instance = processor.load()(
66+
self.root_dir, parent=kwargs.get("parent")
67+
) # Load an instance
68+
self.log.info(
69+
f"Registering {processor.name} processor "
70+
f'"{processor.module_name}.{processor.object_name}"...'
71+
)
72+
self.add_processor(processor_instance)
73+
except Exception as err:
74+
# log and ignore initialization errors
75+
self.log.error(
76+
f"Error registering {processor.name} processor "
77+
f'"{processor.module_name}.{processor.object_name}" - {err}'
78+
)
7379

7480
def add_processor(self, processor):
7581
self.log.debug(f"Registering {processor.type.value} runtime processor '{processor.name}'")

setup.cfg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ papermill.engine =
155155
[options.packages.find]
156156
exclude =
157157
docs*
158-
tests
159-
tests.*
160-
elyra.tests.*
158+
tests*
161159

162160
[flake8]
163161
application-import-names = elyra, test

0 commit comments

Comments
 (0)