-
Notifications
You must be signed in to change notification settings - Fork 301
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
feat: add options to output registered entity summary #3028
base: master
Are you sure you want to change the base?
feat: add options to output registered entity summary #3028
Conversation
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
Code Review Agent Run Status
|
47d8b92
to
dda078c
Compare
Code Review Agent Run Status
|
ef2743a
to
0395846
Compare
Signed-off-by: paullongtan <[email protected]>
Signed-off-by: paullongtan <[email protected]>
Signed-off-by: paullongtan <[email protected]>
0395846
to
9bba92f
Compare
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.
Nice first PR! I think you can add more unit tests.
- yaml
- testing registration without specifying
--summary-dir
else: | ||
summary_dir = os.getcwd() | ||
|
||
summary_file = f"registration_summary.{summary_format}" |
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.
Does this mean that the other registration may overwrite the summary? I think we could name the file with other unique names (ie. tmp file, py file name, wf name, version number)
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.
Yes! The summary will be overwritten if the registration is rerun.
|
||
except Exception as e: | ||
if not skip_errors: | ||
raise e | ||
print_registration_status(og_id, success=False) | ||
result["status"] = "failed" |
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.
If it fails, what will the values of other keys be?
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.
The values of the other keys(id, type, version) are pre-computed before registration. Thus, the values will not be empty even if the registration fails.
The values are from:
result = {
"id": og_id.name,
"type": og_id.resource_type_name(),
"version": og_id.version,
"status": "skipped", # default status
}
where og_id is the id of the entity's template / entity itself.
Code Review Agent Run #9a3edbActionable Suggestions - 3
Additional Suggestions - 1
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
result = { | ||
"id": og_id.name, | ||
"type": og_id.resource_type_name(), | ||
"version": og_id.version, | ||
"status": "skipped", # default status | ||
} |
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.
Consider adding more detailed status information in the result
dictionary. The current status field only captures high-level states ('skipped', 'success', 'failed'). Additional fields like error_message
and timestamp
could provide more context for debugging and monitoring.
Code suggestion
Check the AI-generated fix before applying
result = { | |
"id": og_id.name, | |
"type": og_id.resource_type_name(), | |
"version": og_id.version, | |
"status": "skipped", # default status | |
} | |
result = { | |
"id": og_id.name, | |
"type": og_id.resource_type_name(), | |
"version": og_id.version, | |
"status": "skipped", # default status | |
"timestamp": datetime.datetime.now().isoformat(), | |
"error_message": "", | |
"details": {} | |
} |
Code Review Run #9a3edb
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
supported_format = ["json", "yaml"] | ||
if summary_format not in supported_format: | ||
raise ValueError(f"Unsupported file format: {summary_format}") |
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.
Consider using a set for supported_format
instead of a list since we're only checking membership. This would provide O(1) lookup instead of O(n). Could be defined as supported_format = {'json', 'yaml'}
.
Code suggestion
Check the AI-generated fix before applying
supported_format = ["json", "yaml"] | |
if summary_format not in supported_format: | |
raise ValueError(f"Unsupported file format: {summary_format}") | |
if summary_format not in {"json", "yaml"}: | |
raise ValueError(f"Unsupported file format: {summary_format}") |
Code Review Run #9a3edb
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
"--summary-format", | ||
"-f", | ||
required=False, | ||
type=click.Choice(["json", "yaml"], case_sensitive=False), | ||
default=None, | ||
help="Set output format for registration summary. Lists registered workflows, tasks, and launch plans. 'json' and 'yaml' supported.", | ||
) | ||
@click.option( | ||
"--summary-dir", | ||
required=False, | ||
type=click.Path(dir_okay=True, file_okay=False, writable=True, resolve_path=True), | ||
default=None, | ||
help="Directory to save registration summary. Uses current working directory if not specified.", | ||
) |
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.
Consider adding validation for summary-format
and summary-dir
options. When summary-format
is specified but summary-dir
is not, the summary may not be saved correctly. Consider making summary-dir
required when summary-format
is provided.
Code suggestion
Check the AI-generated fix before applying
"--summary-format", | |
"-f", | |
required=False, | |
type=click.Choice(["json", "yaml"], case_sensitive=False), | |
default=None, | |
help="Set output format for registration summary. Lists registered workflows, tasks, and launch plans. 'json' and 'yaml' supported.", | |
) | |
@click.option( | |
"--summary-dir", | |
required=False, | |
type=click.Path(dir_okay=True, file_okay=False, writable=True, resolve_path=True), | |
default=None, | |
help="Directory to save registration summary. Uses current working directory if not specified.", | |
) | |
"--summary-format", | |
"-f", | |
required=False, | |
type=click.Choice(["json", "yaml"], case_sensitive=False), | |
default=None, | |
help="Set output format for registration summary. Lists registered workflows, tasks, and launch plans. 'json' and 'yaml' supported.", | |
callback=validate_summary_options, | |
) | |
"--summary-dir", | |
required=False, | |
type=click.Path(dir_okay=True, file_okay=False, writable=True, resolve_path=True), | |
default=None, | |
help="Directory to save registration summary. Uses current working directory if not specified.", | |
callback=validate_summary_options, | |
) |
Code Review Run #9a3edb
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: paullongtan <[email protected]>
…mmary-dir testings to unit test Signed-off-by: paullongtan <[email protected]>
2bbe0d1
to
db9f744
Compare
Code Review Agent Run #a2cf6aActionable Suggestions - 0Review Details
|
Thanks! |
Tracking issue
Closes flyteorg/flyte#3919
Why are the changes needed?
Currently,
pyflyte register
does not have an option to output registered entities to a file. This PR creates such functionality.What changes were proposed in this pull request?
--summary-format
and--summary-dir
to pyflyte register inflytekit/flytekit/clis/sdk_in_container/register.py
.--summary-format
: Sets output format for registration summary. Lists registered workflows, tasks, and launch plans. 'json' and 'yaml' supported.--summary-dir
: Directory to save registration summary. Uses current working directory if not specified.flytekit/flytekit/tools/repo.py
. Results are then saved to designated directory in selected file format.register.py
.How was this patch tested?
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
Enhanced pyflyte register command with new summary output capabilities, adding --summary-format (JSON/YAML) and --summary-dir options. Implementation includes registration result collection and flexible output formats. Added comprehensive test suite to validate summary file generation, output data structure, and proper handling of required fields (id, type, version, status) in registration summaries.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2