Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python virtualenv #159

Merged
merged 5 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
PY_VENV: "source venv/bin/activate"

jobs:
build-ubuntu:
Expand Down Expand Up @@ -66,9 +67,13 @@ jobs:
- name: build & install the 3rd party tools
run: util/build-tools.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down Expand Up @@ -123,11 +128,17 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- name: Run production
run: python3 ./src/prod.py
run: |
${{env.PY_VENV}}
python3 ./src/prod.py
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
PY_VENV: "source venv/bin/activate"

jobs:
build-ubuntu:
Expand Down Expand Up @@ -64,9 +65,13 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down Expand Up @@ -121,11 +126,17 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- name: Run production
run: python3 ./src/prod.py --offline-force
run: |
${{env.PY_VENV}}
python3 ./src/prod.py --offline-force
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down Expand Up @@ -167,6 +178,8 @@ jobs:
# run: util/prep-env.sh
# - name: install dependencies
# run: util/deps-pull.sh
# - name: set Python virtual environment
# run: ${{env.PY_VENV}}
# - name: build & install the unmanaged dependencies
# run: util/deps-build.sh
# - name: build generic
Expand Down
33 changes: 25 additions & 8 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
PY_VENV: "source venv/bin/activate"

jobs:
build-ubuntu:
Expand Down Expand Up @@ -64,9 +65,13 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down Expand Up @@ -121,11 +126,17 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: Configure your rig
run: util/config.sh
run: |
${{env.PY_VENV}}
util/config.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1
- name: Run production
run: python3 ./src/prod.py
run: |
${{env.PY_VENV}}
python3 ./src/prod.py
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
Expand Down Expand Up @@ -170,7 +181,9 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: build generic
run: ./util/ci.sh 1
run: |
${{env.PY_VENV}}
./util/ci.sh 1


test-macos:
Expand Down Expand Up @@ -214,7 +227,11 @@ jobs:
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: build generic
run: ./util/ci.sh
run: |
${{env.PY_VENV}}
./util/ci.sh
- name: Run production
run: python3 ./src/prod.py
run: |
${{env.PY_VENV}}
python3 ./src/prod.py

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# Python
*.pyc
.venv/
venv/

# Build dirs
build/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ cd SolOptXMR # Enter the cloned repo's dir
git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) # Checkout latest tag (master is risky)
./util/prep-env.sh # Prepare the environment - downloads example data and creates useful symlinks
./util/deps-pull.sh # Download the maintaned dependencies
source venv/bin/activate # Activate the Python's virtual environment within this directory.
./util/deps-build.sh # Build and install the unmanaged dependencies (uses sudo for installation)
./util/config.sh # Configure your rig
```

## Building & running
```bash
source venv/bin/activate # Activate the Python's virtual environment within this directory.
./ci-default # Build and run the tests
./soloptxmr.py # Run the prediction with default parameters
./soloptxmr.py --help # Print all the available options
Expand Down
74 changes: 44 additions & 30 deletions util/deps-pull.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
#!/bin/bash -e

cd externals/tsqsim/
./util/deps-pull.sh
cd ../..
tsqsim_deps() {
cd externals/tsqsim/
./util/deps-pull.sh
cd ../..
}

system_deps() {
if [ "$(uname)" == "Darwin" ]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install rapidjson libffi osx-cpu-temp hdf5
echo "Please enable the `at` scheduler manually:"
echo "https://unix.stackexchange.com/questions/478823/making-at-work-on-macos/478840#478840"
elif [ "$(uname)" == "Linux" ]; then
sudo apt install gfortran libffi-dev python3-testresources python3.11-venv
#sudo apt install libboost-all-dev # Only JSON is needed for now
#sudo apt install libffi-dev
sudo apt install rapidjson-dev lm-sensors fswebcam at
fi
}

python_deps() {
python3 -m venv venv
source venv/bin/activate
if pip install -r requirements.txt ; then
echo "pip succeeded."
else
echo "pip requirements failed. Trying a fallback."
pip uninstall -r requirements.txt -y
pip install pandas>=1.4.2 scipy>=1.2.0 numpy>=1.19.3 matplotlib \
pvlib pykrakenapi pyparsing pyrsistent python-dateutil \
python-json-config pytz requests six urllib3 \
beautifulsoup4 wget cairosvg Pillow>=9.1.1 geocoder \
opencv-python screeninfo \
# pytesseract not employed yet
#pip3 install --upgrade
# Curses menu:
#windows-curses==2.3.0 ; sys_platform == 'win32'
# Ascii menu:
#asciimatics==1.13.0
fi
}

tsqsim_deps
system_deps
python_deps

if [ "$(uname)" == "Darwin" ]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install rapidjson libffi osx-cpu-temp hdf5
echo "Please enable the `at` scheduler manually:"
echo "https://unix.stackexchange.com/questions/478823/making-at-work-on-macos/478840#478840"
elif [ "$(uname)" == "Linux" ]; then
sudo apt install gfortran libffi-dev python3-testresources
#sudo apt install libboost-all-dev # Only JSON is needed for now
#sudo apt install libffi-dev
sudo apt install rapidjson-dev lm-sensors fswebcam at
fi

if pip3 install -r requirements.txt ; then
echo "pip succeeded."
else
echo "pip failed. Trying a fallback."
pip3 uninstall -r requirements.txt -y
pip3 install pandas>=1.4.2 scipy>=1.2.0 numpy>=1.19.3 matplotlib \
pvlib pykrakenapi pyparsing pyrsistent python-dateutil \
python-json-config pytz requests six urllib3 \
beautifulsoup4 wget cairosvg Pillow>=9.1.1 geocoder \
opencv-python screeninfo \
# pytesseract not employed yet
#pip3 install --upgrade
# Curses menu:
#windows-curses==2.3.0 ; sys_platform == 'win32'
# Ascii menu:
#asciimatics==1.13.0
fi

Loading