-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add CLI for spatialdata_io. #239
Conversation
…d no additional kwargs**
Co-authored-by: Chiara Schiller <chiara_schiller@t-online.de> Co-authored-by: Florian Wuennemann <flowuenne@gmail.com>
Co-authored-by: Chiara Schiller <chiara_schiller@t-online.de>
Co-authored-by: Chiara Schiller <chiara_schiller@t-online.de>
Co-authored-by: Chiara Schiller <chiara_schiller@t-online.de>
Co-authored-by: Chiara Schiller <chiara_schiller@t-online.de>
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #239 +/- ##
==========================================
+ Coverage 43.68% 50.41% +6.72%
==========================================
Files 23 26 +3
Lines 2353 2644 +291
==========================================
+ Hits 1028 1333 +305
+ Misses 1325 1311 -14
|
Forgot to mention @melonora |
for more information, see https://pre-commit.ci
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.
Hi, thanks again for the PR, nice work!
I made a review, but it will still need to be also reviewed by Luca
Thanks again @migueLib @chiarasch @LLehner @FloWuenne @quentinblampey. I applied the changes suggested from @quentinblampey's code review and reviewed the code myself. I have:
|
One comment:
import click
import inspect
def auto_click(func):
# Get the function's signature
sig = inspect.signature(func)
# Create a Click command decorator
@click.command(help=func.__doc__)
# Add Click options based on the function's parameters
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
for name, param in sig.parameters.items():
# Determine the Click option type
param_type = (
click.INT if param.annotation == int else
click.FLOAT if param.annotation == float else
click.BOOL if param.annotation == bool else
click.STRING
)
# Add the option to the wrapper
wrapper = click.option(
f"--{name.replace('_', '-')}",
default=param.default if param.default is not inspect.Parameter.empty else None,
type=param_type,
show_default=True,
help=f"{param.name} (type: {param.annotation.__name__})"
)(wrapper)
return wrapper
# Example function
@auto_click
def example_function(param1: int = 10, param2: str = "default"):
"""Example function docstring."""
print(f"param1: {param1}, param2: {param2}")
if __name__ == "__main__":
example_function() Starting from this we could consider simplify the code and in this way reduce the maintenance burden (otherwise every time we modify/add/remove readers, or change their docstrings, we need to manually update the CLI). Anyway, it's very good to have a working version for all techs that we can merge already. Thanks again! |
@HelenaLC we are going to merge this soon (I promised you I would have tagged you when the CLI would have been ready and documented). CC @vjcitn |
There was an initial commit done by @FloWuenne in the PR #72.
The commit will add :
This commit should close issue #238 and #231 (? @LLehner, @LucaMarconato, @quentinblampey )
This commit is co-authored by: @chiarasch