Spaces:
Sleeping
Sleeping
Download src/req_changes.py from AstraTeam/astra: direct link, hf CLI and curl.
- Browser
- Download file 637 Bytes
-
https://huggingface.co/spaces/AstraTeam/astra/resolve/refs%2Fpr%2F2/src/req_changes.py
- Command line
-
hf download hf://spaces/AstraTeam/astra@refs/pr/2/src/req_changes.py
-
curl -L -o req_changes.py https://huggingface.co/spaces/AstraTeam/astra/resolve/refs%2Fpr%2F2/src/req_changes.py
637 Bytes
| import yaml | |
| # Load the environment.yml file | |
| with open('src/environment.yml') as file: | |
| env_data = yaml.safe_load(file) | |
| # Open the requirements.txt file for writing | |
| with open('src/requirements.txt', 'w') as req_file: | |
| # Iterate over the dependencies | |
| for dep in env_data['dependencies']: | |
| if isinstance(dep, str): | |
| # Write conda package as is (optional: convert to pip package name if known) | |
| req_file.write(dep + '\n') | |
| elif isinstance(dep, dict) and 'pip' in dep: | |
| # Write pip packages as is | |
| for pip_dep in dep['pip']: | |
| req_file.write(pip_dep + '\n') | |