Skip to content

Commit

Permalink
CI: Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-xmr committed Apr 16, 2022
1 parent 843bdb3 commit 794825b
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 11 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ci-debian

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

# The below variables reduce repetitions across similar targets
env:
APT_SET_CONF: |
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
jobs:
build-ubuntu:
runs-on: ubuntu-latest
env:
CCACHE_TEMPDIR: /tmp/.ccache-temp
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: prepare environment
run: util/prep-env.sh
- name: set apt conf
run: ${{env.APT_SET_CONF}}
- name: install dependencies
run: util/deps-pull.sh
- name: build & install the unmanaged dependencies
run: util/deps-build.sh
- name: build
run: ./ci-default
- name: run demo
run: ./ci-default
# It doesn't make sense for now, since we're not linking Boost statically yet.
- uses: actions/upload-artifact@v3
with:
name: SolOptXMR-ubuntu-latest
path: /home/runner/work/SolOptXMR/SolOptXMR/build/*.png

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

# Build dirs
build/
1 change: 1 addition & 0 deletions ci-default
34 changes: 23 additions & 11 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
config = config_builder.parse_config('config.json')

ELEVATION_KEY = config.generator.ELEVATION_KEY
BUILD_DIR='build/' # TODO: Config

# Not changable: system params
MIN_POWER = config.generator.MIN_POWER
Expand Down Expand Up @@ -77,6 +78,10 @@ def plot_sun(name, elev, bat, usage):
plt.plot(list_to_pd([MAX_USAGE] * len(elev), elev))
plt.grid()
plt.legend(['sun input', 'bat capacity', 'power usage', 'max cap', 'half cap', 'max usage'])
os.makedirs(BUILD_DIR, exist_ok=True)
fout_rel_path = "{}/fig-{}.png".format(BUILD_DIR, name)
print("Saving figure to:",fout_rel_path)
plt.savefig(fout_rel_path)
plt.show()

def proc_data(pos):
Expand Down Expand Up @@ -213,7 +218,7 @@ def get_usage_endor_example(available):
hashrates.append(hashrate)
usage.append(use)

return "Endor's", hashrates, usage, loads, bat_sim, incomes, costs, effs
return "Endor", hashrates, usage, loads, bat_sim, incomes, costs, effs

def get_usage_simple(available):
usage_exp = [MAX_USAGE] * len(available)
Expand Down Expand Up @@ -255,17 +260,17 @@ def print_profits(incomes, costs):
print(f"Total cost = {cost:.2f} USD")
print(f"Total profit = {profit:.2f} USD")
print(f"Profitability = {profitability:.2f} %")

def get_usage(available):
name, hashrates, usage, bat, bat_sim, incomes, costs, effs = get_usage_simple(available)
#name, hashrates, usage, bat, bat_sim, incomes, costs, effs = get_usage_endor_example(available)
print("Algo name: ", name)

def get_usage(available, algo):
name, hashrates, usage, bat, bat_sim, incomes, costs, effs = algo(available)
print("\nAlgo name: ", name)
bat_sim.print_stats(len(available))
print_hashes(hashrates)
print_profits(incomes, costs)
# print(effs) # Check if efficiency is reasonable
#print(effs) # Check if efficiency is reasonable
# return name, list_to_pd(usage, available), list_to_pd(incomes, available), list_to_pd(costs, available), list_to_pd(bat, available)
return name, list_to_pd(usage, available), list_to_pd(bat, available)
return name, list_to_pd(usage, available), list_to_pd(bat, available)


def list_to_pd(listt, df):
return pd.DataFrame(listt, index=df.index.copy())
Expand All @@ -277,11 +282,18 @@ def simul_weather(pos):

return pos

def run_main(elev):
run_algo(elev, get_usage_simple)
run_algo(elev, get_usage_endor_example)

def run_algo(elev, algo):
name, usage, bat = get_usage(elev, algo)
plot_sun(name, elev, bat, usage)

pos = get_sun_positions()
#print(pos)

proc = proc_data(pos)
elev = extr_data(proc)
name, usage, bat = get_usage(elev)
# name, usage, incomes, costs, bat = get_usage(elev)
plot_sun(name, elev, bat, usage)
run_main(elev)

4 changes: 4 additions & 0 deletions util/ci-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -e

python3 src/generator.py

2 changes: 2 additions & 0 deletions util/deps-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh -e

5 changes: 5 additions & 0 deletions util/deps-pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e

#sudo apt install gfortran libffi-dev
#sudo apt install libffi-dev
pip3 install -r requirements.txt
2 changes: 2 additions & 0 deletions util/prep-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh -e

0 comments on commit 794825b

Please sign in to comment.