-
Notifications
You must be signed in to change notification settings - Fork 300
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
Create default launch plan when executing WorkflowBase #707
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4f673e3
Create default lauchplan
pingsutw 516384e
Update comment
pingsutw 17ca892
Added test
pingsutw b511e8e
Fixed lint
pingsutw 8a15ab6
Fixed lint
pingsutw a492ccf
Fixed test
pingsutw abebc0c
Register subworkflow, launchplan node
pingsutw 3b3f9e5
Fixed lint
pingsutw 3a0ec62
Fixed test
pingsutw 004185f
Fixed tests
pingsutw 8958430
Fixed tests
pingsutw d486990
Fixed tests
pingsutw 64a8dda
Fixed tests
pingsutw 8aaedda
Fixed tests
pingsutw 3a33253
Fix tests
pingsutw dbb375a
Fix tests
pingsutw dd5c39b
Fix tests
pingsutw 7cb61a2
Fix tests
pingsutw bab4af4
Fix tests
pingsutw 4482254
Fix tests
pingsutw f804b48
Fixed test
pingsutw fb90ca2
Fixed test
pingsutw 8093ff6
Add link
pingsutw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""Module defining main Flyte backend entrypoint.""" | ||
from __future__ import annotations | ||
|
||
import logging | ||
import os | ||
import time | ||
import typing | ||
|
@@ -15,9 +16,12 @@ | |
|
||
from flytekit.clients.friendly import SynchronousFlyteClient | ||
from flytekit.common import utils as common_utils | ||
from flytekit.common.exceptions.user import FlyteEntityAlreadyExistsException, FlyteEntityNotExistException | ||
from flytekit.configuration import internal | ||
from flytekit.configuration import platform as platform_config | ||
from flytekit.configuration import sdk as sdk_config | ||
from flytekit.configuration import set_flyte_config_file | ||
from flytekit.core import context_manager | ||
from flytekit.core.interface import Interface | ||
from flytekit.loggers import remote_logger | ||
from flytekit.models import filters as filter_models | ||
|
@@ -202,7 +206,6 @@ def __init__( | |
raise user_exceptions.FlyteAssertion("Cannot find flyte admin url in config file.") | ||
|
||
self._client = SynchronousFlyteClient(flyte_admin_url, insecure=insecure, credentials=grpc_credentials) | ||
|
||
# read config files, env vars, host, ssl options for admin client | ||
self._flyte_admin_url = flyte_admin_url | ||
self._insecure = insecure | ||
|
@@ -520,6 +523,8 @@ def _serialize( | |
domain or self.default_domain, | ||
version or self.version, | ||
self.image_config, | ||
# https://github.com/flyteorg/flyte/issues/1359 | ||
env={internal.IMAGE.env_var: self.image_config.default_image.full}, | ||
), | ||
entity=entity, | ||
) | ||
|
@@ -604,6 +609,24 @@ def _( | |
) | ||
return self.fetch_launch_plan(**resolved_identifiers) | ||
|
||
def _register_entity_if_not_exists(self, entity: WorkflowBase, resolved_identifiers_dict: dict): | ||
# Try to register all the entity in WorkflowBase including LaunchPlan, PythonTask, or subworkflow. | ||
node_identifiers_dict = deepcopy(resolved_identifiers_dict) | ||
for node in entity.nodes: | ||
try: | ||
node_identifiers_dict["name"] = node.flyte_entity.name | ||
if isinstance(node.flyte_entity, WorkflowBase): | ||
self._register_entity_if_not_exists(node.flyte_entity, node_identifiers_dict) | ||
self.register(node.flyte_entity, **node_identifiers_dict) | ||
elif isinstance(node.flyte_entity, PythonTask) or isinstance(node.flyte_entity, LaunchPlan): | ||
self.register(node.flyte_entity, **node_identifiers_dict) | ||
else: | ||
raise NotImplementedError(f"We don't support registering this kind of entity: {node.flyte_entity}") | ||
except FlyteEntityAlreadyExistsException: | ||
logging.info(f"{entity.name} already exists") | ||
except Exception as e: | ||
logging.info(f"Failed to register entity {entity.name} with error {e}") | ||
|
||
#################### | ||
# Execute Entities # | ||
#################### | ||
|
@@ -884,11 +907,23 @@ def _( | |
"""Execute an @workflow-decorated function.""" | ||
resolved_identifiers = self._resolve_identifier_kwargs(entity, project, domain, name, version) | ||
resolved_identifiers_dict = asdict(resolved_identifiers) | ||
|
||
try: | ||
flyte_workflow: FlyteWorkflow = self.fetch_workflow(**resolved_identifiers_dict) | ||
except Exception: | ||
except FlyteEntityNotExistException: | ||
logging.info("Try to register FlyteWorkflow because it wasn't found in Flyte Admin!") | ||
self._register_entity_if_not_exists(entity, resolved_identifiers_dict) | ||
flyte_workflow: FlyteWorkflow = self.register(entity, **resolved_identifiers_dict) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wild-endeavor we will register parent workflow here |
||
flyte_workflow.guessed_python_interface = entity.python_interface | ||
|
||
ctx = context_manager.FlyteContext.current_context() | ||
try: | ||
self.fetch_launch_plan(**resolved_identifiers_dict) | ||
except FlyteEntityNotExistException: | ||
logging.info("Try to register default launch plan because it wasn't found in Flyte Admin!") | ||
default_lp = LaunchPlan.get_default_launch_plan(ctx, entity) | ||
self.register(default_lp, **resolved_identifiers_dict) | ||
|
||
return self.execute( | ||
flyte_workflow, | ||
inputs, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a link to flyteorg/flyte#1359 as a comment here?