Add a `parameterize` keyword argument to `scriptify`
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the scriptify entry point and the existing subcommands behavior. Define how parameterized functions, extends, multiple parameterizations, command-line syntax, and configuration should interact before implementing anything. Done means the command-line and TOML examples work without breaking existing subcommands.
Written by the indexing model from the issue text.
Description
allow arguments in for the function passed to scriptify (including those passed by extends) to be parameterized by a set of subcommands that contain additional arguments. Something like the following:
def say_hello(friendliness: int, greeting: str = "hello"):
if friendliness > 0:
return f"{greeting} friend!"
else:
greeting
def say_goodbye(friendliness: int, see_again: bool = False):
if friendliness > 0:
greeting = "so long"
else:
greeting = "goodbye"
if not see_again:
return f"{greeting} forever!"
else:
return f"{greeting} until next time!"
@scriptify(message=[say_hello, say_goodbye])
def main(greeter: str, message: str):
print(f"Message from {greeter}:\n{message}")
Which could be executed from the command line like:
$ greet --greeter Thom say_hello --friendliness 1 --greeting hi
Message from Thom:
Hi friend!
Under the hood, the parser would pass the friendliness and greeting arguments to say_hello, use those to create a message, and pass this message to main. This implementation should be pretty straightforward, but there is a question about how would this interact with the existing subcommands, and relatedly could we support multiple parameterizations? How would this look in the config? Maybe something like
[tool.typeo]
greeter = "Thom"
[tool.typeo.message.say_hello]
friendliness = 1
greeting = "hey"
[tool.typeo.message.say_goodbye]
friendliness = 0
see_again = false
and the command line execution might be greet --typeo .:::say_hello, with the extra colon indicating that there's no subcommand, but each colon after that reflects a different parameterization, in the order in which they're passed (would there be any order in this **kwargs-like setup?).
- Dominant language
- Python
- Stars
- 0
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ML4GW/typeo
-
Archive this repo?Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day