Skip to content
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

cli: update parsing inputs #333

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion .github/workflows/ci-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ jobs:
pip list

- name: run CLI
working-directory: ./scripts
working-directory: ./requirements
run: |
python -m lightning_utilities.cli version
python -m lightning_utilities.cli --help
python -m lightning_utilities.cli requirements set-oldest --req_files="cli.txt"
python -m lightning_utilities.cli requirements set-oldest --req_files='["cli.txt", "docs.txt"]'

cli-guardian:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [Unreleased] - 2024-MM-DD

### Changed

- CLI: update parsing inputs ([#333](https://github.com/Lightning-AI/utilities/pull/333))



## [0.11.9] - 2024-11-19

### Changed
Expand Down
12 changes: 9 additions & 3 deletions src/lightning_utilities/cli/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import glob
import os.path
from pprint import pprint
from typing import Sequence
from typing import Sequence, Union

REQUIREMENT_ROOT = "requirements.txt"
REQUIREMENT_FILES_ALL: list = glob.glob(os.path.join("requirements", "*.txt"))
Expand All @@ -14,8 +14,12 @@
REQUIREMENT_FILES_ALL += [REQUIREMENT_ROOT]


def prune_pkgs_in_requirements(packages: Sequence[str], req_files: Sequence[str] = REQUIREMENT_FILES_ALL) -> None:
def prune_pkgs_in_requirements(
packages: Union[str, Sequence[str]], req_files: Union[str, Sequence[str]] = REQUIREMENT_FILES_ALL
) -> None:
"""Remove some packages from given requirement files."""
if isinstance(packages, str):
packages = [packages]
if isinstance(req_files, str):
req_files = [req_files]
for req in req_files:
Expand Down Expand Up @@ -44,7 +48,9 @@ def _replace_min(fname: str) -> None:
fw.write(req)


def replace_oldest_ver(req_files: Sequence[str] = REQUIREMENT_FILES_ALL) -> None:
def replace_oldest_ver(req_files: Union[str, Sequence[str]] = REQUIREMENT_FILES_ALL) -> None:
"""Replace the min package version by fixed one."""
if isinstance(req_files, str):
req_files = [req_files]
for fname in req_files:
_replace_min(fname)
Loading