mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Add jsonargparse support (#403)
This commit is contained in:
15
examples/frameworks/jsonargparse/jsonargparser_command.py
Normal file
15
examples/frameworks/jsonargparse/jsonargparser_command.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from jsonargparse import CLI
|
||||
from clearml import Task
|
||||
|
||||
|
||||
class Main:
|
||||
def __init__(self, prize: int = 100):
|
||||
self.prize = prize
|
||||
|
||||
def person(self, name: str):
|
||||
return "{} won {}!".format(name, self.prize)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Task.init(project_name="examples", task_name="jsonargparse command", auto_connect_frameworks={"pytorch_lightning": False})
|
||||
print(CLI(Main))
|
||||
@@ -0,0 +1,19 @@
|
||||
from dataclasses import dataclass
|
||||
from jsonargparse import ArgumentParser
|
||||
from clearml import Task
|
||||
|
||||
|
||||
@dataclass
|
||||
class Arg2:
|
||||
opt1: str = "from default 1"
|
||||
opt2: str = "from default 2"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Task.init(project_name="examples", task_name="jsonargparse nested namespaces", auto_connect_frameworks={"pytorch-lightning": False})
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("--arg1.opt1", default="from default 1")
|
||||
parser.add_argument("--arg1.opt2", default="from default 2")
|
||||
parser.add_argument("--arg2", type=Arg2, default=Arg2())
|
||||
parser.add_argument("--not-nested")
|
||||
print(parser.parse_args())
|
||||
2
examples/frameworks/jsonargparse/requirements.txt
Normal file
2
examples/frameworks/jsonargparse/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
clearml
|
||||
jsonargparse
|
||||
Reference in New Issue
Block a user