Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/find-unused-caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def main(repository: str, token: str, age_days: float = 7, output_file: str = "u
from jsonargparse import auto_cli, set_parsing_settings

set_parsing_settings(parse_optionals_as_positionals=True)
auto_cli(main)
auto_cli(main, as_positional=False)
except ImportError:
import sys

Expand Down
2 changes: 1 addition & 1 deletion scripts/adjust-torch-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def main(requirements_path: str, torch_version: Optional[str] = None) -> None:
from jsonargparse import auto_cli, set_parsing_settings

set_parsing_settings(parse_optionals_as_positionals=True)
auto_cli(main)
auto_cli(main, as_positional=False)
except (ModuleNotFoundError, ImportError):
logging.warning(
"Expected `jsonargparse` is not installed,"
Expand Down
2 changes: 1 addition & 1 deletion scripts/inject-selector-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main(folder: str, selector_name: str) -> None:
from jsonargparse import auto_cli, set_parsing_settings

set_parsing_settings(parse_optionals_as_positionals=True)
auto_cli(main)
auto_cli(main, as_positional=False)
except (ModuleNotFoundError, ImportError):
logging.warning(
"Expected `jsonargparse` is not installed,"
Expand Down
15 changes: 13 additions & 2 deletions tests/scripts/test_adjust_torch_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import subprocess
import sys

import pytest

from scripts import _PATH_SCRIPTS

REQUIREMENTS_SAMPLE = """
Expand All @@ -29,13 +31,22 @@
"""


def test_adjust_torch_versions_call(tmp_path) -> None:
@pytest.mark.parametrize("args", ["positional", "optional", "mixed"])
def test_adjust_torch_versions_call(args, tmp_path) -> None:
path_script = os.path.join(_PATH_SCRIPTS, "adjust-torch-versions.py")
path_req_file = str(tmp_path / "requirements.txt")
with open(path_req_file, "w", encoding="utf8") as fopen:
fopen.write(REQUIREMENTS_SAMPLE)

return_code = subprocess.call([sys.executable, path_script, path_req_file, "1.10.0"]) # noqa: S603
main_params = (("requirements_path", path_req_file), ("torch_version", "1.10.0"))
cli_call = [sys.executable, path_script]
if args == "positional":
cli_call += [p[1] for p in main_params]
elif args == "optional":
cli_call += [f"--{p[0]}={p[1]}" for p in main_params]
elif args == "mixed":
cli_call += [main_params[0][1], f"--{main_params[1][0]}={main_params[1][1]}"]
return_code = subprocess.call(cli_call) # noqa: S603
assert return_code == 0

with open(path_req_file, encoding="utf8") as fopen:
Expand Down
Loading