From 0f43a948e4e592b84aa1fb80f08bef93acbf0406 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 2 Jan 2024 12:07:39 +0100 Subject: [PATCH 1/2] Package code (#9) * Add basic files * Use environment.yaml and simplify verification script --- README.md | 17 +++++++++++++++++ applications/learn_mnist.py | 7 +------ environment.yaml | 5 +++++ setup.py | 12 ++++++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 README.md create mode 100644 environment.yaml create mode 100644 setup.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..90f61ad --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# edugrad + +## Installation + + git clone https://github.com/tostenzel/edugrad + cd edugrad + + # Setup environment in edugrad/.env and install requirements with conda from environment.yaml + conda create --prefix .env + conda activate .env/ + conda env update --file environment.yaml --prefix .env + + # Install edugrad from source in editable mode to enable absolute imports + pip install -e . + + # Verify installation + python applications/learn_mnist.py \ No newline at end of file diff --git a/applications/learn_mnist.py b/applications/learn_mnist.py index 137378e..b41f37c 100755 --- a/applications/learn_mnist.py +++ b/applications/learn_mnist.py @@ -1,11 +1,6 @@ -import sys import os - -# Add the project root to the Python path -project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -sys.path.append(project_root) - import gzip + import numpy as np from edugrad import Tensor diff --git a/environment.yaml b/environment.yaml new file mode 100644 index 0000000..7cb20fc --- /dev/null +++ b/environment.yaml @@ -0,0 +1,5 @@ +name: .env +channels: + - defaults +dependencies: + - numpy diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..788b61e --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup + + +setup(name='edugrad', + version='0.1.0', + description='', + author='Tobias Stenzel', + author_email='tobias.stenzel@mailbox.org', + url='https://github.com/tostenzel/edugrad', + packages=['edugrad'], + license='', + ) \ No newline at end of file From ff4fcfe57645bb313fb38346f1e01145ebfd439f Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 2 Jan 2024 12:17:15 +0100 Subject: [PATCH 2/2] Add basic CI (#10) * Add basic files * Use environment.yaml and simplify verification script * Add github workflow for conda and pytest * Move config to correct folder * Change env name in ci * Use code from README * Fix SyntaxError * Again * Try different env path * Fix bug * Try again * Add pytest as dependency * Again * Again * Again * Again * Again * Add dummy test * Fix bug * Can I leave that out? * Finalize Tests CI * Rename ci file * Package the code #2 (#7) * Add basic files * Use environment.yaml and simplify verification script --- .github/workflows/Tests.yaml | 33 +++++++++++++++++++++++++++++++++ environment.yaml | 3 +++ tests/test_dummy.py | 3 +++ 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/Tests.yaml create mode 100644 tests/test_dummy.py diff --git a/.github/workflows/Tests.yaml b/.github/workflows/Tests.yaml new file mode 100644 index 0000000..b95cfa1 --- /dev/null +++ b/.github/workflows/Tests.yaml @@ -0,0 +1,33 @@ +name: Tests + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + # Checkout the code at the commit (incl. branch) that triggered the workflow + - name: Checkout Repository + uses: actions/checkout@v2 + + # ------------------------------------------------------------------------------------------------------------------ + # Resemble installation section in README.md + - name: Setup Conda Environment + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: '.env' + environment-file: 'environment.yaml' + auto-activate-base: false + + - name: Install edugrad + run: | + pip install -e . + # ------------------------------------------------------------------------------------------------------------------ + + - name: Run Tests + # Execute the commands in a bash login shell, ensuring that the shell's environment is fully initialized. + shell: bash -l {0} + run: | + pytest tests \ No newline at end of file diff --git a/environment.yaml b/environment.yaml index 7cb20fc..3ccaa9a 100644 --- a/environment.yaml +++ b/environment.yaml @@ -3,3 +3,6 @@ channels: - defaults dependencies: - numpy + + # tests + - pytest diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..e7bfc24 --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,3 @@ + +def test_dummy(): + assert True == True \ No newline at end of file