Conversation
workpackages/wp_mergin.py
Outdated
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("mergin_project", nargs="?") | ||
| parser.add_argument("--cache-dir", nargs="?") | ||
| parser.add_argument("--max_workers", nargs="?", type=int, const=8, default=8) |
There was a problem hiding this comment.
| parser.add_argument("--max_workers", nargs="?", type=int, const=8, default=8) | |
| parser.add_argument("--max-workers", type=int, default=8) |
not sure if we need the "nargs" and "const" specified? also better to use dash --max-workers than underscore.
I guess the --cache-dir and the positional mergin_project arguments above probably also do not need to use nargs="?") - a likely extra addition for me when I did not know much about argparse :)
There was a problem hiding this comment.
nargs="?" is to specify argument which can be optional and I would keep it. "const=8" and "default=8" are to handle all possible cases like:
- no flag at all
- flag without value specified
- flag with value specified
workpackages/wp_mergin.py
Outdated
| wp_new = set() | ||
|
|
||
| for wp in wp_config.wp_names: | ||
| def prepare_work_packages(wp): |
There was a problem hiding this comment.
| def prepare_work_packages(wp): | |
| def prepare_work_package(wp): |
(it is just one that we prepare inside)
workpackages/wp_mergin.py
Outdated
| mergin.client_push.push_project_wait(job) | ||
| mergin.client_push.push_project_finalize(job) | ||
| return True | ||
| def push_mergin_project(mc, directory, max_retires=3, sleep_time=5): |
There was a problem hiding this comment.
| def push_mergin_project(mc, directory, max_retires=3, sleep_time=5): | |
| def push_mergin_project(mc, directory, max_retries=3, sleep_time=5): |
workpackages/wp_mergin.py
Outdated
| """Push data to all Mergin Maps projects""" | ||
|
|
||
| for wp in wp_config.wp_names: | ||
| def push_work_packages(wp): |
There was a problem hiding this comment.
| def push_work_packages(wp): | |
| def push_work_package(wp): |
workpackages/wp_mergin.py
Outdated
| if push_mergin_project(ctx.mc, wp_dir): | ||
| print("Uploaded a new version: " + mergin.MerginProject(wp_dir).metadata["version"]) | ||
| else: | ||
| print("No changes (not creating a new version).") |
There was a problem hiding this comment.
Looks like the indentation went wrong here, and all this code would be run only when if wp_name in wp_new
--max-workersCLI argument (by default 8)