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

Modify arg default #524

Merged
merged 19 commits into from
Oct 16, 2023
Merged

Modify arg default #524

merged 19 commits into from
Oct 16, 2023

Conversation

PhilippeMoussalli
Copy link
Contributor

No description provided.

@@ -191,14 +192,22 @@ def outputs_additional_subsets(self) -> bool:

@property
def args(self) -> t.Mapping[str, Argument]:
def _get_default(argument_info):
if "default" in argument_info:
if argument_info["default"] == "None":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed for arguments that are taken from the componentSpec which always have a string type

Copy link
Member

Choose a reason for hiding this comment

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

It might be a bit cleaner to include this in the Argument class. I think this should work:

@dataclass
class Argument:

    default: t.Any

    def __post_init__(self):
        self.default = None if self.default == "None" else self.default

@@ -289,6 +290,30 @@ def compile(
pipeline.validate(run_id=run_id)
logger.info(f"Compiling {pipeline.name} to {output_path}")

def set_component_exec_args(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was previously defined in the ComponentSpec but in fact should be evaluated at runtime. Optional arguments with defaults should not be included in the arg section of the componentOp otherwise some errors occur

I1016 10:42:19.355692      27 cache.go:116] Connecting to cache endpoint 10.0.12.128:8887
[2023-10-16 10:42:21,330 | fondant.cli | INFO] Component `LoadFromHubComponent` found in module main
usage: fondant [-h] [--component_spec COMPONENT_SPEC] [--cache CACHE]
               [--input_partition_rows INPUT_PARTITION_ROWS]
               [--cluster_type CLUSTER_TYPE] [--client_kwargs CLIENT_KWARGS]
fondant: error: argument --input_partition_rows: invalid int value: "{{$.inputs.parameters['input_partition_rows']}}"

Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

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

Thanks @PhilippeMoussalli! The pipeline that was failing before now succeeds.

@@ -191,14 +192,22 @@ def outputs_additional_subsets(self) -> bool:

@property
def args(self) -> t.Mapping[str, Argument]:
def _get_default(argument_info):
if "default" in argument_info:
if argument_info["default"] == "None":
Copy link
Member

Choose a reason for hiding this comment

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

It might be a bit cleaner to include this in the Argument class. I think this should work:

@dataclass
class Argument:

    default: t.Any

    def __post_init__(self):
        self.default = None if self.default == "None" else self.default

@@ -34,7 +34,7 @@ class Argument:
name: str
description: str
type: str
default: t.Any = None
default: t.Optional[t.Any] = None
Copy link
Member

Choose a reason for hiding this comment

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

t.Any already includes t.Optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh good to know

@PhilippeMoussalli
Copy link
Contributor Author

Thanks @PhilippeMoussalli! The pipeline that was failing before now succeeds.

Glad it works :) I hope everything is fine now with the argument but some things might still pop up

@PhilippeMoussalli PhilippeMoussalli merged commit 4814e2d into main Oct 16, 2023
4 checks passed
@PhilippeMoussalli PhilippeMoussalli deleted the modify-arg-default branch October 16, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants