From 57c8e534675ce937689c23fb2ba22cd171b7d6c8 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 00:07:38 -0500 Subject: [PATCH 01/14] dependency caching --- .github/workflows/train_workflow.yml | 28 +++++++++++--- requirements.txt | 4 +- test_workflow.py | 58 ++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 test_workflow.py diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 53d55c2a..0256ae2b 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -5,17 +5,35 @@ on: script_content: description: 'Content of train.py' required: true - type: string # Explicitly specify the type + type: string jobs: train: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Cache PyTorch + uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + ${{ runner.tool_cache }}/Python + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies run: | - pip install numpy - # pip install torch - need to find a way to cache this otherwise it will take a long time to install - + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Create and run training script run: | echo "${{ inputs.script_content }}" > train.py @@ -24,7 +42,7 @@ jobs: - name: Upload logs uses: actions/upload-artifact@v3 - if: always() # Upload logs whether the job succeeds or fails + if: always() with: name: training-logs path: training.log \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 944b75c6..ee43bc41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ PyGithub aiohttp discord.py -audioop-lts # discord.py imports using * syntax python-dotenv -requests \ No newline at end of file +requests +pytest \ No newline at end of file diff --git a/test_workflow.py b/test_workflow.py new file mode 100644 index 00000000..9d7b33e0 --- /dev/null +++ b/test_workflow.py @@ -0,0 +1,58 @@ +import subprocess +import time +import os +import logging + +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' +) +logger = logging.getLogger(__name__) + +def test_pytorch_install(): + cache_dir = os.path.expanduser("~/.cache/pip") + + if os.path.exists(cache_dir): + subprocess.run(["rm", "-rf", cache_dir]) + + start_time = time.time() + result = subprocess.run( + ["pip", "install", "-r", "requirements.txt"], + capture_output=True, + text=True + ) + + if result.returncode != 0: + logger.error(f"pip install failed with output:\n{result.stdout}\n{result.stderr}") + raise AssertionError("First pip install failed") + + first_run_time = time.time() - start_time + logger.info(f"First run (no cache) took: {first_run_time:.2f} seconds") + + start_time = time.time() + result = subprocess.run( + ["pip", "install", "-r", "requirements.txt"], + capture_output=True, + text=True + ) + + if result.returncode != 0: + logger.error(f"Second pip install failed with output:\n{result.stdout}\n{result.stderr}") + raise AssertionError("Second pip install failed") + + second_run_time = time.time() - start_time + logger.info(f"Second run (with cache) took: {second_run_time:.2f} seconds") + + improvement = (first_run_time - second_run_time) / first_run_time * 100 + logger.info(f"Cache improved installation time by {improvement:.1f}%") + + assert improvement > 0, "Cache did not improve installation time" + assert improvement > 10, f"Cache improvement ({improvement:.1f}%) was less than 10%" + +if __name__ == "__main__": + try: + import pytest + pytest.main([__file__]) + except ImportError: + test_pytorch_install() \ No newline at end of file From 4737c286df133a5e3568d0e1680fb2315729fcd3 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 00:22:23 -0500 Subject: [PATCH 02/14] local test workflow --- .github/workflows/train_workflow.yml | 2 +- test_workflow.py | 119 ++++++++++++++++----------- 2 files changed, 73 insertions(+), 48 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 0256ae2b..ec66a9fc 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip + pip install numpy torch pip install -r requirements.txt - name: Create and run training script diff --git a/test_workflow.py b/test_workflow.py index 9d7b33e0..84478ff3 100644 --- a/test_workflow.py +++ b/test_workflow.py @@ -1,58 +1,83 @@ -import subprocess -import time import os +import subprocess +import tempfile +import shutil import logging +import sys logging.basicConfig( level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s', - datefmt='%Y-%m-%d %H:%M:%S' + format='%(asctime)s - %(levelname)s - %(message)s' ) logger = logging.getLogger(__name__) -def test_pytorch_install(): - cache_dir = os.path.expanduser("~/.cache/pip") - - if os.path.exists(cache_dir): - subprocess.run(["rm", "-rf", cache_dir]) - - start_time = time.time() - result = subprocess.run( - ["pip", "install", "-r", "requirements.txt"], - capture_output=True, - text=True - ) - - if result.returncode != 0: - logger.error(f"pip install failed with output:\n{result.stdout}\n{result.stderr}") - raise AssertionError("First pip install failed") - - first_run_time = time.time() - start_time - logger.info(f"First run (no cache) took: {first_run_time:.2f} seconds") - - start_time = time.time() - result = subprocess.run( - ["pip", "install", "-r", "requirements.txt"], - capture_output=True, - text=True - ) - - if result.returncode != 0: - logger.error(f"Second pip install failed with output:\n{result.stdout}\n{result.stderr}") - raise AssertionError("Second pip install failed") - - second_run_time = time.time() - start_time - logger.info(f"Second run (with cache) took: {second_run_time:.2f} seconds") - - improvement = (first_run_time - second_run_time) / first_run_time * 100 - logger.info(f"Cache improved installation time by {improvement:.1f}%") - - assert improvement > 0, "Cache did not improve installation time" - assert improvement > 10, f"Cache improvement ({improvement:.1f}%) was less than 10%" +def simulate_workflow(script_content): + with tempfile.TemporaryDirectory() as temp_dir: + logger.info(f"Created temporary directory: {temp_dir}") + + logger.info("Creating virtual environment...") + subprocess.run(["python3.10", "-m", "venv", f"{temp_dir}/venv"]) + + pip_path = f"{temp_dir}/venv/bin/pip" if os.name != 'nt' else f"{temp_dir}/venv/Scripts/pip" + python_path = f"{temp_dir}/venv/bin/python" if os.name != 'nt' else f"{temp_dir}/venv/Scripts/python" + logger.info(f"Using pip at: {pip_path}") + logger.info(f"Using python at: {python_path}") + + logger.info("Upgrading pip...") + subprocess.run([pip_path, "install", "--upgrade", "pip"]) + + logger.info("Installing numpy and torch...") + subprocess.run([pip_path, "install", "numpy", "torch"]) + + logger.info("Installing requirements...") + subprocess.run([pip_path, "install", "-r", "requirements.txt"]) + + train_path = os.path.join(temp_dir, "train.py") + logger.info(f"Writing training script to {train_path}") + with open(train_path, "w") as f: + f.write(script_content) + + log_path = os.path.join(temp_dir, "training.log") + logger.info(f"Running training script, logging to {log_path}") + with open(log_path, "w") as log_file: + result = subprocess.run( + [python_path, "train.py"], + cwd=temp_dir, + stdout=log_file, + stderr=subprocess.STDOUT + ) + + logger.info("Reading training logs...") + with open(log_path, "r") as f: + logs = f.read() + + logger.info(f"Training completed with return code: {result.returncode}") + return result.returncode, logs if __name__ == "__main__": try: - import pytest - pytest.main([__file__]) - except ImportError: - test_pytorch_install() \ No newline at end of file + logger.info("Checking Python 3.10 installation...") + python_version = subprocess.run(["python", "-c", "import sys; print(sys.version.split()[0])"], + capture_output=True, + text=True, + check=True).stdout.strip() + if not python_version.startswith("3.10"): + logger.error(f"Python 3.10 is required but found {python_version}") + sys.exit(1) + logger.info(f"Found Python version: {python_version}") + + test_script = """ +import numpy as np +import torch +print("Test script running...") +print("NumPy version:", np.__version__) +print("PyTorch version:", torch.__version__) +""" + + return_code, logs = simulate_workflow(test_script) + print("\nTest output:") + print(logs) + + except (subprocess.CalledProcessError, FileNotFoundError): + logger.error("Failed to determine Python version") + sys.exit(1) \ No newline at end of file From 45973361a4ddb17730d644469631fc3d93654228 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 00:41:43 -0500 Subject: [PATCH 03/14] local test update with uv --- .github/workflows/train_workflow.yml | 1 - test_workflow.py | 71 ++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index ec66a9fc..b19eb19d 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -32,7 +32,6 @@ jobs: - name: Install dependencies run: | pip install numpy torch - pip install -r requirements.txt - name: Create and run training script run: | diff --git a/test_workflow.py b/test_workflow.py index 84478ff3..66420faa 100644 --- a/test_workflow.py +++ b/test_workflow.py @@ -4,6 +4,7 @@ import shutil import logging import sys +import time logging.basicConfig( level=logging.INFO, @@ -11,7 +12,22 @@ ) logger = logging.getLogger(__name__) -def simulate_workflow(script_content): +def install_packages(package_names, pip_path, use_uv=False): + if use_uv: + subprocess.run(["pip", "install", "uv"]) + return subprocess.run(["uv", "pip", "install"] + package_names) + else: + return subprocess.run([pip_path, "install"] + package_names) + +def simulate_workflow(script_content, clear_cache=False, use_uv=False): + start_time = time.time() + + if clear_cache: + cache_dir = os.path.expanduser("~/.cache/pip") + if os.path.exists(cache_dir): + logger.info("Clearing pip cache...") + shutil.rmtree(cache_dir) + with tempfile.TemporaryDirectory() as temp_dir: logger.info(f"Created temporary directory: {temp_dir}") @@ -27,7 +43,10 @@ def simulate_workflow(script_content): subprocess.run([pip_path, "install", "--upgrade", "pip"]) logger.info("Installing numpy and torch...") - subprocess.run([pip_path, "install", "numpy", "torch"]) + install_start = time.time() + install_packages(["numpy", "torch"], pip_path, use_uv=use_uv) + install_duration = time.time() - install_start + logger.info(f"Package installation took {install_duration:.2f} seconds") logger.info("Installing requirements...") subprocess.run([pip_path, "install", "-r", "requirements.txt"]) @@ -52,7 +71,10 @@ def simulate_workflow(script_content): logs = f.read() logger.info(f"Training completed with return code: {result.returncode}") - return result.returncode, logs + + total_duration = time.time() - start_time + logger.info(f"Total workflow duration: {total_duration:.2f} seconds") + return result.returncode, logs, total_duration if __name__ == "__main__": try: @@ -66,16 +88,47 @@ def simulate_workflow(script_content): sys.exit(1) logger.info(f"Found Python version: {python_version}") - test_script = """ + numpy_test_script = """ import numpy as np + +matrix1 = np.array([[1, 2], [3, 4]]) +matrix2 = np.array([[5, 6], [7, 8]]) +result = np.matmul(matrix1, matrix2) +print("Matrix multiplication result:\\n", result) +""" + + pytorch_test_script = """ import torch -print("Test script running...") -print("NumPy version:", np.__version__) -print("PyTorch version:", torch.__version__) + +tensor1 = torch.tensor([[1, 2], [3, 4]], dtype=torch.float) +tensor2 = torch.tensor([[5, 6], [7, 8]], dtype=torch.float) +result = torch.matmul(tensor1, tensor2) +print("Tensor multiplication result:\\n", result) """ - return_code, logs = simulate_workflow(test_script) - print("\nTest output:") + logger.info("\nRunning test with cleared cache...") + return_code, logs, uncached_time = simulate_workflow(numpy_test_script, clear_cache=True) + + logger.info("Running test with cached packages...") + return_code, logs, cached_time = simulate_workflow(numpy_test_script, clear_cache=False) + + logger.info("Running test with UV package installer...") + return_code, logs, uv_time = simulate_workflow(numpy_test_script, clear_cache=False, use_uv=True) + + print("\n" + "="*50) + print("BENCHMARK RESULTS".center(50)) + print("="*50) + print(f"{'Test Type':<30}{'Duration':<20}") + print("-"*50) + print(f"{'With Cache':<30}{f'{cached_time:.2f}s':<20}") + print(f"{'Without Cache':<30}{f'{uncached_time:.2f}s':<20}") + print(f"{'With UV':<30}{f'{uv_time:.2f}s':<20}") + print(f"{'Cache Speedup':<30}{f'{uncached_time - cached_time:.2f}s':<20}") + print(f"{'UV vs Cache Speedup':<30}{f'{cached_time - uv_time:.2f}s':<20}") + print("="*50) + + print("\nTest Output:") + print("-"*50) print(logs) except (subprocess.CalledProcessError, FileNotFoundError): From 696dda44479297eaebd4d0416c048694c77771f8 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 00:54:11 -0500 Subject: [PATCH 04/14] end to end test --- test_workflow.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/test_workflow.py b/test_workflow.py index 66420faa..5103f674 100644 --- a/test_workflow.py +++ b/test_workflow.py @@ -12,21 +12,27 @@ ) logger = logging.getLogger(__name__) -def install_packages(package_names, pip_path, use_uv=False): +def install_packages(package_names, pip_path, use_uv=False, python_path=None): if use_uv: - subprocess.run(["pip", "install", "uv"]) - return subprocess.run(["uv", "pip", "install"] + package_names) + subprocess.run([pip_path, "install", "uv"]) + subprocess.run([python_path, "-m", "uv", "pip", "install", "--no-deps"] + package_names) + subprocess.run([python_path, "-m", "uv", "pip", "install"] + package_names) + return subprocess.CompletedProcess(args=[], returncode=0) else: return subprocess.run([pip_path, "install"] + package_names) def simulate_workflow(script_content, clear_cache=False, use_uv=False): start_time = time.time() + pip_cache_dir = os.path.expanduser("~/.cache/pip") + uv_cache_dir = os.path.expanduser("~/.cache/uv") + if clear_cache: - cache_dir = os.path.expanduser("~/.cache/pip") - if os.path.exists(cache_dir): - logger.info("Clearing pip cache...") - shutil.rmtree(cache_dir) + logger.info("Clearing package caches...") + if os.path.exists(pip_cache_dir): + shutil.rmtree(pip_cache_dir) + if os.path.exists(uv_cache_dir): + shutil.rmtree(uv_cache_dir) with tempfile.TemporaryDirectory() as temp_dir: logger.info(f"Created temporary directory: {temp_dir}") @@ -44,13 +50,17 @@ def simulate_workflow(script_content, clear_cache=False, use_uv=False): logger.info("Installing numpy and torch...") install_start = time.time() - install_packages(["numpy", "torch"], pip_path, use_uv=use_uv) + if use_uv: + install_packages(["numpy", "torch"], pip_path, use_uv=True, python_path=python_path) + else: + cmd = [pip_path, "install"] + if clear_cache: + cmd.append("--no-cache-dir") + cmd.extend(["numpy", "torch"]) + subprocess.run(cmd) install_duration = time.time() - install_start logger.info(f"Package installation took {install_duration:.2f} seconds") - logger.info("Installing requirements...") - subprocess.run([pip_path, "install", "-r", "requirements.txt"]) - train_path = os.path.join(temp_dir, "train.py") logger.info(f"Writing training script to {train_path}") with open(train_path, "w") as f: @@ -106,14 +116,14 @@ def simulate_workflow(script_content, clear_cache=False, use_uv=False): print("Tensor multiplication result:\\n", result) """ - logger.info("\nRunning test with cleared cache...") + logger.info("\nRunning test with UV package installer...") + return_code, logs, uv_time = simulate_workflow(numpy_test_script, clear_cache=False, use_uv=True) + + logger.info("\nRunning test without cache...") return_code, logs, uncached_time = simulate_workflow(numpy_test_script, clear_cache=True) - logger.info("Running test with cached packages...") + logger.info("\nRunning test with cached packages...") return_code, logs, cached_time = simulate_workflow(numpy_test_script, clear_cache=False) - - logger.info("Running test with UV package installer...") - return_code, logs, uv_time = simulate_workflow(numpy_test_script, clear_cache=False, use_uv=True) print("\n" + "="*50) print("BENCHMARK RESULTS".center(50)) From 0384a3cb1e692754f59bc82582dee99e9ad60c4f Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:18:17 -0500 Subject: [PATCH 05/14] using uv and added pytorch example --- .github/workflows/train_workflow.yml | 16 +++++----------- torch/train.py | 6 ++++++ 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 torch/train.py diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index b19eb19d..45ceddaf 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -19,24 +19,18 @@ jobs: with: python-version: '3.10' - - name: Cache PyTorch - uses: actions/cache@v3 - with: - path: | - ~/.cache/pip - ${{ runner.tool_cache }}/Python - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Install dependencies run: | - pip install numpy torch + uv pip install numpy torch --no-cache - name: Create and run training script run: | echo "${{ inputs.script_content }}" > train.py - cat train.py # Debug: print the content python train.py > training.log 2>&1 - name: Upload logs diff --git a/torch/train.py b/torch/train.py new file mode 100644 index 00000000..d18e84d9 --- /dev/null +++ b/torch/train.py @@ -0,0 +1,6 @@ +import torch + +x = torch.randn(2, 3) +y = torch.randn(3, 2) +z = torch.matmul(x, y) +print(z) \ No newline at end of file From 76969f415b7622efa46360a5b99d128479c9674a Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:22:23 -0500 Subject: [PATCH 06/14] make venv --- .github/workflows/train_workflow.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 45ceddaf..e9c22b3e 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -24,13 +24,16 @@ jobs: curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install dependencies + - name: Create virtual environment and install dependencies run: | + uv venv + source .venv/bin/activate uv pip install numpy torch --no-cache - name: Create and run training script run: | echo "${{ inputs.script_content }}" > train.py + source .venv/bin/activate python train.py > training.log 2>&1 - name: Upload logs From a520f19002bb5507589ff091a48892b2e2c03ed9 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:29:03 -0500 Subject: [PATCH 07/14] pip caching --- .github/workflows/train_workflow.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index e9c22b3e..76e18847 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -18,17 +18,16 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' + cache: 'pip' - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.cargo/bin" >> $GITHUB_PATH + uses: astral-sh/setup-uv@v1 - name: Create virtual environment and install dependencies run: | uv venv source .venv/bin/activate - uv pip install numpy torch --no-cache + uv pip install --no-deps numpy torch - name: Create and run training script run: | From 8434013866f2010dae7b58b9b07fc4cdc22eff13 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:31:30 -0500 Subject: [PATCH 08/14] cache uv deps --- .github/workflows/train_workflow.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 76e18847..4b3ddbe8 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -18,11 +18,20 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' - cache: 'pip' - name: Install uv uses: astral-sh/setup-uv@v1 + - name: Cache UV packages + uses: actions/cache@v3 + with: + path: | + ~/.cache/uv + .venv + key: ${{ runner.os }}-uv-numpy-torch-v1 + restore-keys: | + ${{ runner.os }}-uv- + - name: Create virtual environment and install dependencies run: | uv venv From e7ba478c8a75a1ca672b46dfc1b0a967a879d338 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:35:17 -0500 Subject: [PATCH 09/14] testing --- .github/workflows/train_workflow.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 4b3ddbe8..143730b9 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -42,8 +42,10 @@ jobs: run: | echo "${{ inputs.script_content }}" > train.py source .venv/bin/activate - python train.py > training.log 2>&1 - + # python train.py > training.log 2>&1 + cat train.py + python train.py + - name: Upload logs uses: actions/upload-artifact@v3 if: always() From 81850129e741d2f267079f069bd641a26b56b615 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:37:29 -0500 Subject: [PATCH 10/14] typing extensions --- .github/workflows/train_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 143730b9..fa044084 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -36,7 +36,7 @@ jobs: run: | uv venv source .venv/bin/activate - uv pip install --no-deps numpy torch + uv pip install --no-deps numpy torch typing_extensions - name: Create and run training script run: | From 1bcbfb05ee8d4347bcac41541f5dd3d1fc2fa047 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:41:16 -0500 Subject: [PATCH 11/14] remove no-deps --- .github/workflows/train_workflow.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index fa044084..836dc37f 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -36,15 +36,13 @@ jobs: run: | uv venv source .venv/bin/activate - uv pip install --no-deps numpy torch typing_extensions + uv pip install numpy torch - name: Create and run training script run: | echo "${{ inputs.script_content }}" > train.py source .venv/bin/activate - # python train.py > training.log 2>&1 - cat train.py - python train.py + python train.py > training.log 2>&1 - name: Upload logs uses: actions/upload-artifact@v3 From 044609d172ff7f19dc9f1f8fa9d0ba661e7d3c14 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:47:16 -0500 Subject: [PATCH 12/14] speed up cache --- .github/workflows/train_workflow.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 836dc37f..0cd1914b 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -28,9 +28,9 @@ jobs: path: | ~/.cache/uv .venv - key: ${{ runner.os }}-uv-numpy-torch-v1 + key: ${{ runner.os }}-uv-numpy-torch-v2 restore-keys: | - ${{ runner.os }}-uv- + ${{ runner.os }}-uv-numpy-torch- - name: Create virtual environment and install dependencies run: | @@ -49,4 +49,15 @@ jobs: if: always() with: name: training-logs - path: training.log \ No newline at end of file + path: training.log + retention-days: 1 + if-no-files-found: warn + + cleanup: + runs-on: ubuntu-latest + needs: train + if: always() + steps: + - uses: geekyeggo/delete-artifact@v2 + with: + name: training-logs \ No newline at end of file From e878a9f552cdb76e34591935e1fc7e19a82a5e24 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:54:49 -0500 Subject: [PATCH 13/14] speed up caching --- .github/workflows/train_workflow.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index 0cd1914b..c47ddba2 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -28,15 +28,19 @@ jobs: path: | ~/.cache/uv .venv - key: ${{ runner.os }}-uv-numpy-torch-v2 + key: ${{ runner.os }}-uv-py3.10-${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-uv-numpy-torch- + ${{ runner.os }}-uv-py3.10- + enableCrossOsArchive: true + lookup-only: true + compression-level: 3 - name: Create virtual environment and install dependencies run: | + echo "torch\nnumpy" > requirements.txt uv venv source .venv/bin/activate - uv pip install numpy torch + uv pip install -r requirements.txt - name: Create and run training script run: | @@ -51,13 +55,4 @@ jobs: name: training-logs path: training.log retention-days: 1 - if-no-files-found: warn - - cleanup: - runs-on: ubuntu-latest - needs: train - if: always() - steps: - - uses: geekyeggo/delete-artifact@v2 - with: - name: training-logs \ No newline at end of file + if-no-files-found: warn \ No newline at end of file From bd8b462bee9a83298a6abe7339395f1fa1343e8c Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 7 Nov 2024 01:56:02 -0500 Subject: [PATCH 14/14] fix --- .github/workflows/train_workflow.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/train_workflow.yml b/.github/workflows/train_workflow.yml index c47ddba2..1b763cca 100644 --- a/.github/workflows/train_workflow.yml +++ b/.github/workflows/train_workflow.yml @@ -33,11 +33,10 @@ jobs: ${{ runner.os }}-uv-py3.10- enableCrossOsArchive: true lookup-only: true - compression-level: 3 - name: Create virtual environment and install dependencies run: | - echo "torch\nnumpy" > requirements.txt + printf "torch\nnumpy\n" > requirements.txt uv venv source .venv/bin/activate uv pip install -r requirements.txt