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

feat: Added result commands #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

AncientPatata
Copy link
Contributor

Motivation

The current version of the CLI doesn't have result-specific commands.

Description

Added commands for :

  • Listing results
  • Getting details about results
  • Creating results
  • Deleting result data
  • Uploading data to results

Along with a parameter type for parsing result inputs.

Testing

Unit testing for different failing scenarios, serialization and commandline argument parsing.

Impact

Not applicable.

Additional Information

None.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have thoroughly tested my modifications and added tests when necessary.
  • Tests pass locally and in the CI.
  • I have assessed the performance impact of my modifications.

Copy link

github-actions bot commented Jan 16, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
763 697 91% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: a550aed by action🐍

@AncientPatata AncientPatata force-pushed the ad/add_results_commands branch 5 times, most recently from 0311513 to 42e76b0 Compare January 16, 2025 14:40
@AncientPatata AncientPatata force-pushed the ad/add_results_commands branch from 42e76b0 to a550aed Compare January 16, 2025 14:54


@results.command(name="list")
@click.argument("session-id", required=True, type=str)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this argument. The user is free to list results as needed. The filters are here for that!
This change must also be applied on task list command.

"-f",
"--filter",
"filter_with",
type=FilterParam("Partition"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Small typo that should be “Result”.

metavar="FILTER EXPR",
)
@click.option(
"--sort-by", type=FieldParam("Task"), required=False, help="Attribute of task to sort with."
Copy link
Contributor

Choose a reason for hiding this comment

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

Idem typo!

results_list = []
while True:
total, results = results_client.list_results(
result_filter=(Result.session_id == session_id) & filter_with
Copy link
Contributor

Choose a reason for hiding this comment

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

here just put the filter and ignore the session_id!

"-r",
"--result",
"results",
type=ResultParam(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a more explicit name like ResultNameDataParam.

Comment on lines +143 to +146
raise click.FileError(
str(result_data_filepath),
f"File {str(result_data_filepath)} not found for result {res[0]}",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done in the ResultParam.

@click.option(
"-r",
"--result",
"results",
Copy link
Contributor

Choose a reason for hiding this comment

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

result_definitions

)

# Enforce that at least one mutual option is provided
if self.require_one and not (mutex or self.name in opts):
Copy link
Contributor

Choose a reason for hiding this comment

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

if self.require_one and not mutex and self.name not in opts

# Enforce that at least one mutual option is provided
if self.require_one and not (mutex or self.name in opts):
raise click.UsageError(
f"At least one of the following options must be provided: {', '.join(self.mutual | {self.name})}."
Copy link
Contributor

Choose a reason for hiding this comment

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

.join(self.mutual)

@@ -188,3 +189,67 @@ def convert(
)
cls = getattr(common, self.base_struct)
return getattr(cls, value)


class ResultParam(click.ParamType):
Copy link
Contributor

Choose a reason for hiding this comment

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

Rework the implementation using namedtuples. The conversion should return a list of namedtuples with values for name and data.

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