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

CLI Fixes / NPM dependency updates #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

cvs0
Copy link

@cvs0 cvs0 commented Oct 20, 2024

CLI Fixes / NPM Dependency Updates

Summary of items Affected

  • _parse_type_annotation: Enhanced validation for argument metadata.
  • parse_action: Improved checks for decorators and their arguments.
  • connect cli command, improved config reading.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
    • Inside web: npm run prettier
    • Inside docs: pnpm prettier
    • Inside workflow-runner: cargo fmt
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings (npm run lint)
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes
    • Inside backend: poetry run pytest
    • Inside workflow-runner: cargo test

* `_parse_type_annotation`: Enhanced validation for argument metadata.
* `parse_action`: Improved checks for decorators and their arguments.
* used `pop` for key removal in the `connect` cli command
* updated NPM dependencies for website
Copy link

vercel bot commented Oct 20, 2024

@cvs0 is attempting to deploy a commit to the Admyral Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Oct 20, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@danielgrittner danielgrittner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Appreciate it!

admyral/cli/connect.py Outdated Show resolved Hide resolved
admyral/compiler/action_parser.py Outdated Show resolved Hide resolved
Comment on lines +56 to +57
action_decorator = decorator
break
Copy link
Member

Choose a reason for hiding this comment

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

I think we should actually raise an error here because display_name and display_namespace must always be defined.

if action_decorator is None:
raise ValueError("Action function must have the @action decorator.")

if isinstance(action_decorator, ast.Call):
Copy link
Member

Choose a reason for hiding this comment

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

Can become an assert if we throw in the case of isinstance(decorator, ast.Name).

if isinstance(action_decorator, ast.Call):
# Ensure the decorator has arguments if expected
if not action_decorator.keywords:
raise ValueError("The @action decorator must include arguments.")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
raise ValueError("The @action decorator must include arguments.")
raise ValueError("The arguments display_name and display_namespace must be defined for the @action decorator.")

Comment on lines +67 to +69
for arg in action_decorator.keywords:
if not isinstance(arg.value, (ast.Constant, ast.List)):
raise ValueError(f"Invalid argument type in @action decorator: {arg.arg} must be a constant or list.")
Copy link
Member

Choose a reason for hiding this comment

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

Good idea to validate the values. However, I would suggest a different approach due to maintainability and granularity reasons. It would probably make sense to add a parameter value validation function in admyral/action.py which is then used before a new action is constructed in the decorator and also here. If we maintain this function in action.py and a new parameter is added then it is harder to miss updating the validation function.

Comment on lines +241 to +242
if not arg_metadata_params:
raise ValueError("ArgumentMetadata must contain at least one parameter.")
Copy link
Member

Choose a reason for hiding this comment

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

This check is not needed imo because this is already handled by ArgumentMetadata.model_validate

Copy link

vercel bot commented Oct 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
admyral-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 7:37pm

cvs0 and others added 2 commits October 22, 2024 15:19
Co-authored-by: Daniel Grittner <danielgrittner@web.de>
Co-authored-by: Daniel Grittner <danielgrittner@web.de>
@danielgrittner
Copy link
Member

@cvs0 Just checking in: do you plan to work on the requested changes any time soon? otherwise I'll take this over

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.

3 participants