Skip to content

Commit

Permalink
fixing some notebooks [freezing] (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Jul 22, 2024
1 parent 8d4a7c2 commit 7b418e8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 105 deletions.
46 changes: 35 additions & 11 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,31 @@ def get_running_torch_version() -> str:
return ""


def _parse_package_name(pkg: str, keys: str = " !<=>[]@", egg_name: str = "#egg=") -> str:
"""Parsing just the package name.
Args:
pkg: full package info including version coming from `pip freeze
keys: char separators for parsing package name and version or other info
egg_name: eventual passing egg names once isnralled from URL
Examples:
>>> _parse_package_name("torch==2.0.1+cu118")
'torch'
>>> _parse_package_name("torch-cluster==1.6.3+pt20cu118")
'torch-cluster'
>>> _parse_package_name("torch_geometric==2.4.0")
'torch_geometric'
"""
if egg_name in pkg:
pkg = pkg[pkg.index(egg_name) + len(egg_name) :]
if any(c in pkg for c in keys):
ix = min(pkg.index(c) for c in keys if c in pkg)
pkg = pkg[:ix]
return pkg


_TORCH_VERSION = get_running_torch_version()
_CUDA_VERSION = get_running_cuda_version()
_RUNTIME_VERSIONS = dict(
Expand Down Expand Up @@ -750,18 +775,17 @@ def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str:
req += meta.get("requirements", [])
req = [r.strip() for r in req]

def _parse_package_name(pkg: str, keys: str = " !<=>[]@", egg_name: str = "#egg=") -> str:
"""Parsing just the package name."""
if egg_name in pkg:
pkg = pkg[pkg.index(egg_name) + len(egg_name) :]
if any(c in pkg for c in keys):
ix = min(pkg.index(c) for c in keys if c in pkg)
pkg = pkg[:ix]
return pkg

require = {_parse_package_name(r) for r in req if r}
env = {_parse_package_name(p): p for p in freeze.freeze()}
meta["environment"] = [env[r] for r in require]
# duplicate package name/key for cases with -/_ separator
env = {
**{_parse_package_name(p).replace("-", "_"): p for p in freeze.freeze()},
**{_parse_package_name(p).replace("_", "-"): p for p in freeze.freeze()},
}
# for debugging reasons print the env and requested packages
try:
meta["environment"] = [env[r] for r in require]
except KeyError:
raise KeyError(f"Missing matching requirements: {require}\n within environment: {env}")
meta["published"] = datetime.now().isoformat()

fmeta = os.path.join(base_path, folder) + ".yaml"
Expand Down
4 changes: 2 additions & 2 deletions course_UvA-DL/06-graph-neural-networks/.meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ requirements:
- torch-sparse
- torch-cluster
- torch-spline-conv
- torch-geometric
- lightning>=2.0.0
- "torch-geometric>=2.0.0,<2.5.0"
- "lightning>=2.0.0"
pip__find-link:
# - https://pytorch-geometric.com/whl/torch-1.8.0+cu101.html
- https://pytorch-geometric.com/whl/torch-%(TORCH_MAJOR_DOT_MINOR)s.0+%(DEVICE)s.html
Expand Down
1 change: 1 addition & 0 deletions lightning_examples/finetuning-scheduler/.meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: |
and foundation model weights. The required dependencies are installed via the finetuning-scheduler ``[examples]`` extra.
requirements:
- finetuning-scheduler[examples]>=2.0.0
- datasets<2.18.0 # todo: some compatibility issue, please pass the argument `trust_remote_code=True`
- torch>=1.12.1 # to avoid https://github.com/pytorch/pytorch/issues/80809 with torch 1.12.0
accelerator:
- GPU
2 changes: 1 addition & 1 deletion lightning_examples/text-transformers/.meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: |
(We just show CoLA and MRPC due to constraint on compute/disk)
requirements:
- transformers
- datasets
- datasets<2.18.0 # todo: some compatibility issue, please pass the argument `trust_remote_code=True`
- scipy
- scikit-learn
- torchtext>=0.9
Expand Down
21 changes: 0 additions & 21 deletions templates/img-classify/.meta.yml

This file was deleted.

70 changes: 0 additions & 70 deletions templates/img-classify/classify.py

This file was deleted.

0 comments on commit 7b418e8

Please sign in to comment.