Skip to content

Commit

Permalink
Use Python to extract version info
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantinjdobler committed Nov 7, 2023
1 parent 0b5b3d1 commit 2fed007
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/scripts/extract_version_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
import sys
import yaml

if len(sys.argv) != 2:
print("Usage: python extract_pytorch_version.py <package_name>")
sys.exit(1)

package_name = sys.argv[1]

# Load the lock file
try:
with open('conda-lock.yml', 'r') as lock_file:
lock_data = yaml.safe_load(lock_file)
except FileNotFoundError:
print("Lock file 'conda-lock.yml' not found.")
sys.exit(1)

# Extract the version of the specified package
package_version = None
for package in lock_data['package']:
if package['name'] == package_name and package['platform'] == 'linux-64':
package_version = package['version']
break

if package_version:
print(package_version)
else:
print(f"{package_name}-not-found")
11 changes: 6 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ jobs:
username: konstantinjdobler # change this
password: ${{secrets.DOCKER_REGISTRY_TOKEN}}
- name: Get torch version for amd
run: "echo TORCH_VERSION_AMD=$(cat conda-lock.yml | grep -E -A 4 'name: pytorch$' |
tail -n1 | grep -Eo [0-9]+.[0-9]+.[0-9]+) >> $GITHUB_ENV"
run: "echo TORCH_VERSION_AMD=$(.github/scripts/release.py pytorch) >> $GITHUB_ENV"
- name: Get cuda version for amd
run: "echo CUDA_VERSION_AMD=$(cat conda-lock.yml | grep -E -A 4 'name:
pytorch-cuda$' | tail -n1 | grep -Eo [0-9]+.[0-9]+) >> $GITHUB_ENV"
run: "echo CUDA_VERSION_AMD=$(.github/scripts/release.py pytorch-cuda) >> $GITHUB_ENV"
- name: Print version info
run: |
echo "TORCH_VERSION_AMD=$TORCH_VERSION_AMD"
echo "CUDA_VERSION_AMD=$CUDA_VERSION_AMD"
- name: Build and push AMD
uses: docker/build-push-action@v4
with:
Expand All @@ -48,4 +50,3 @@ jobs:
push: true
# change these tags to match your Docker Hub repo
tags: konstantinjdobler/nlp-research-template:pytorch${{env.TORCH_VERSION_AMD}}-cuda${{env.CUDA_VERSION_AMD}}, konstantinjdobler/nlp-research-template:latest

0 comments on commit 2fed007

Please sign in to comment.