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

Adding missing fields to FlyteTask remote entity #3093

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions flytekit/remote/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def __init__(
custom,
container=None,
task_type_version: int = 0,
security_context=None,
config=None,
k8s_pod=None,
sql=None,
extended_resources=None,
Comment on lines +52 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding parameter validation checks

Consider adding parameter validation for the new parameters security_context, k8s_pod, sql, and extended_resources to ensure they contain valid values before being passed to the task template.

Code suggestion
Check the AI-generated fix before applying
 @@ -51,6 +51,14 @@
          task_type_version: int = 0,
          security_context=None,
          config=None,
          k8s_pod=None,
          sql=None,
          extended_resources=None,
 +        if security_context is not None and not isinstance(security_context, dict):
 +            raise ValueError('security_context must be a dict or None')
 +        if k8s_pod is not None and not isinstance(k8s_pod, dict):
 +            raise ValueError('k8s_pod must be a dict or None')
 +        if sql is not None and not isinstance(sql, dict):
 +            raise ValueError('sql must be a dict or None')
 +        if extended_resources is not None and not isinstance(extended_resources, dict):
 +            raise ValueError('extended_resources must be a dict or None')

Code Review Run #42cb06


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

should_register: bool = False,
):
super(FlyteTask, self).__init__(
Expand All @@ -61,7 +65,11 @@ def __init__(
custom,
container=container,
task_type_version=task_type_version,
security_context=security_context,
config=config,
k8s_pod=k8s_pod,
sql=sql,
extended_resources=extended_resources,
)
)
self._should_register = should_register
Expand Down Expand Up @@ -146,6 +154,10 @@ def k8s_pod(self):
def sql(self):
return self.template.sql

@property
def extended_resources(self):
return self.template.extended_resources

@property
def should_register(self) -> bool:
return self._should_register
Expand All @@ -172,6 +184,11 @@ def promote_from_model(cls, base_model: _task_model.TaskTemplate) -> FlyteTask:
custom=base_model.custom,
container=base_model.container,
task_type_version=base_model.task_type_version,
security_context=base_model.security_context,
config=base_model.config,
k8s_pod=base_model.k8s_pod,
sql=base_model.sql,
extended_resources=base_model.extended_resources,
)
# Override the newly generated name if one exists in the base model
if not base_model.id.is_empty:
Expand Down
3 changes: 3 additions & 0 deletions tests/flytekit/unit/remote/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,9 @@ def dynamic0():
def workflow1():
return dynamic0()

mock_client.get_task.return_value.closure.compiled_task.template.sql = None
mock_client.get_task.return_value.closure.compiled_task.template.k8s_pod = None

rr = FlyteRemote(
Config.for_sandbox(),
default_project="flytesnacks",
Expand Down