~kvikshaug/dotfiles

a12e4a0464c1217cdf7f0866b30ef25e028c87a9 — Ali Kaafarani 11 months ago a1cb77e
updates
32 files changed, 0 insertions(+), 863 deletions(-)

D .workflow/.gitignore
D .workflow/_models.py
D .workflow/_wf.py
D .workflow/benssalong.py
D .workflow/cobrapy.py
D .workflow/dd-decaf-caffeine.py
D .workflow/dd-decaf-design_storage.py
D .workflow/dd-decaf-escher.py
D .workflow/dd-decaf-iam.py
D .workflow/dd-decaf-map_storage.py
D .workflow/dd-decaf-memote_service_frontend.py
D .workflow/dd-decaf-memote_webservice.py
D .workflow/dd-decaf-metabolic_ninja.py
D .workflow/dd-decaf-metanetx.py
D .workflow/dd-decaf-model_storage.py
D .workflow/dd-decaf-simulations.py
D .workflow/dd-decaf-warehouse.py
D .workflow/hodl.py
D .workflow/home.py
D .workflow/kvikshaug.py
D .workflow/p2pool.py
D .workflow/tv.py
D .workflow/unseenbio-metrics.py
D .workflow/unseenbio-myub.py
D .workflow/unseenbio-oesd-backend.py
D .workflow/unseenbio-oesd-frontend.py
D .workflow/unseenbio-terms-of-service.py
D .workflow/unseenbio-ubdb.py
D .workflow/unseenbio-uboms.py
D .workflow/unseenbio-unseenbio.com.py
D .workflow/unseenbio-vacations.py
D bin/drive
D .workflow/.gitignore => .workflow/.gitignore +0 -1
@@ 1,1 0,0 @@
/__pycache__/

D .workflow/_models.py => .workflow/_models.py +0 -4
@@ 1,4 0,0 @@
from collections import namedtuple

Command = namedtuple("Command", ("argument", "script"))
Project = namedtuple("Project", ("path", "commands"))

D .workflow/_wf.py => .workflow/_wf.py +0 -57
@@ 1,57 0,0 @@
#!/usr/bin/env /home/kvikshaug/.pyenv/versions/home/bin/python

import importlib.util
import os
import sys

path = os.path.dirname(os.path.realpath(__file__))
projects = []
for filename in os.listdir(path):
    full_path = f"{path}/{filename}"
    if not os.path.isfile(full_path):
        continue
    if filename.startswith("_"):
        continue
    if filename.startswith("."):
        continue

    spec = importlib.util.spec_from_file_location(filename, full_path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    projects.append(module.project)

cwd = os.getcwd().replace("/home/kvikshaug/", "")
args = " ".join(sys.argv[1:])

try:
    project = [p for p in projects if p.path == cwd][0]
except IndexError:
    print(f"no workflow defined for path: {cwd}, valid project paths are:")
    for project in sorted(projects):
        print(f"  {project.path}")
    sys.exit(-1)

try:
    command = [c for c in project.commands if c.argument == args][0]
except IndexError:
    maxlen = max(len(c.argument) for c in project.commands)
    for i, command in enumerate(project.commands):
        print(f"wf {command.argument.ljust(maxlen)}")
        for line in command.script:
            print(f"  {line}")
        if i < len(project.commands) - 1:
            print()
    sys.exit(-1)

exit_codes = []
for line in command.script:
    print(f"wf: {line}")
    exit_codes.append(os.WEXITSTATUS(os.system(line)))

if any(code > 0 for code in exit_codes):
    print("wf: non-zero exit code:")
    for line, code in zip(command.script, exit_codes):
        print(f"  {line}: exit {code}")
    sys.exit(-1)
else:
    sys.exit(0)

D .workflow/benssalong.py => .workflow/benssalong.py +0 -6
@@ 1,6 0,0 @@
from _models import Command, Project

project = Project("code/benssalong.no", [
    Command("start", ["PASSWORD=dev FLASK_ENV=development FLASK_APP=benssalong.py flask run"]),
    Command("black", ["black ."]),
])

D .workflow/cobrapy.py => .workflow/cobrapy.py +0 -5
@@ 1,5 0,0 @@
from _models import Command, Project

project = Project("code/cobrapy", [
    Command("test", ["python setup.py test"]),
])

D .workflow/dd-decaf-caffeine.py => .workflow/dd-decaf-caffeine.py +0 -9
@@ 1,9 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/caffeine", [
    Command("serve", ["npx vue-cli-service serve --port 4200"]),
    Command("lint", ["npx vue-cli-service lint --no-fix --max-warnings 0"]),
    Command("format", ["npx vue-cli-service lint"]),
    Command("test", ["npx vue-cli-service test:unit"]),
    Command("install local escher", ["cp -va ~/code/dd-decaf/escher/dist/* ~/code/dd-decaf/caffeine/node_modules/@dd-decaf/escher/dist"]),
])

D .workflow/dd-decaf-design_storage.py => .workflow/dd-decaf-design_storage.py +0 -34
@@ 1,34 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/design-storage", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/postgres-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database designs;\"",
        "docker compose exec postgres psql -U postgres -c \"create database designs_test;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-escher.py => .workflow/dd-decaf-escher.py +0 -9
@@ 1,9 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/escher", [
    Command("build", ["npm run-script build"]),
    Command("watch", ["npm run-script watch"]),
    Command("start", ["npm run-script start"]),
    Command("clean", ["npm run-script clean"]),
    Command("test", ["npm run-script test"]),
])

D .workflow/dd-decaf-iam.py => .workflow/dd-decaf-iam.py +0 -35
@@ 1,35 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/iam", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/postgres-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("keypair", ["docker compose run --rm web ssh-keygen -t rsa -b 2048 -f keys/rsa -N "" -m PEM"]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database iam;\"",
        "docker compose exec postgres psql -U postgres -c \"create database iam_test;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-map_storage.py => .workflow/dd-decaf-map_storage.py +0 -34
@@ 1,34 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/map-storage", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/postgres-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database maps;\"",
        "docker compose exec postgres psql -U postgres -c \"create database maps_test;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-memote_service_frontend.py => .workflow/dd-decaf-memote_service_frontend.py +0 -8
@@ 1,8 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/memote-service-frontend", [
    Command("serve", ["npx vue-cli-service serve --port 4200"]),
    Command("lint", ["npx vue-cli-service lint --no-fix --max-warnings 0"]),
    Command("test", ["npx vue-cli-service test:unit"]),
    Command("format", ["npx vue-cli-service lint"]),
])

D .workflow/dd-decaf-memote_webservice.py => .workflow/dd-decaf-memote_webservice.py +0 -18
@@ 1,18 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/memote-webservice", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("format", ["docker compose run --rm web isort --recursive src tests"]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-metabolic_ninja.py => .workflow/dd-decaf-metabolic_ninja.py +0 -34
@@ 1,34 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/metabolic-ninja", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build gcr.io/dd-decaf-cfbf6/modeling-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database metabolic_ninja;\"",
        "docker compose exec postgres psql -U postgres -c \"create database metabolic_ninja_testing;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "# docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-metanetx.py => .workflow/dd-decaf-metanetx.py +0 -28
@@ 1,28 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/metanetx", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/wsgi-base:alpine-compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("reaction-names", ["docker compose run --rm web python ./scripts/generate_reaction_names.py"]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-model_storage.py => .workflow/dd-decaf-model_storage.py +0 -34
@@ 1,34 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/model-storage", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/postgres-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database model_storage;\"",
        "docker compose exec postgres psql -U postgres -c \"create database model_storage_test;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-simulations.py => .workflow/dd-decaf-simulations.py +0 -29
@@ 1,29 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/simulations", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build gcr.io/dd-decaf-cfbf6/modeling-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("update-models", ["docker compose run --rm web python scripts/update_models.py"]),
    Command("update-salts", ["docker compose run --rm web python scripts/update_salts.py"]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/dd-decaf-warehouse.py => .workflow/dd-decaf-warehouse.py +0 -33
@@ 1,33 0,0 @@
from _models import Command, Project

project = Project("code/dd-decaf/warehouse", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", [
        "docker run --rm -v `pwd`/requirements:/build dddecaf/postgres-base:compiler pip-compile --generate-hashes --upgrade --output-file /build/requirements.txt /build/requirements.in",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("databases", [
        "docker compose up -d postgres",
        "./scripts/wait_for_postgres.sh",
        "docker compose exec postgres psql -U postgres -c \"create database testing;\"",
        "docker compose run --rm web flask db upgrade",
    ]),
    Command("format", [
        "docker compose run --rm web isort --recursive src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf license",
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf test",
    ]),
    Command("license", ["./scripts/verify_license_headers.sh src tests"]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only --recursive src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("safety", ["docker compose run --rm web safety check"]),
])

D .workflow/hodl.py => .workflow/hodl.py +0 -34
@@ 1,34 0,0 @@
from _models import Command, Project

project = Project("code/hodl", [
    Command("flake8", ["flake8 hodl"]),
    Command("isort check", ["isort --check-only hodl"]),
    Command("black check", ["black --check hodl/*"]),
    Command("safety", ["safety check --full-report"]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
    ]),
    Command("format", [
        "isort hodl",
        "black hodl/*",
    ]),

    Command("print_history", ["python -m hodl.main print_history"]),
    Command("save_history_csv", ["python -m hodl.main save_history_csv"]),

    Command("print_holdings", ["python -m hodl.main print_holdings"]),
    Command("save_holdings_csv", ["python -m hodl.main save_holdings_csv"]),

    Command("print_realizations", ["python -m hodl.main print_realizations"]),
    Command("save_realizations_csv", ["python -m hodl.main save_realizations_csv"]),

    Command("print_yearly_results", ["python -m hodl.main print_yearly_results"]),
    Command("print_yearly_results_per_currency", ["python -m hodl.main print_yearly_results_per_currency"]),
    Command("render_charts", ["python -m hodl.main render_charts"]),

    Command("parse_bitstamp", ["python hodl/parse_bitstamp.py"]),
    Command("open", ["firefox dist/charts.html"]),
])

D .workflow/home.py => .workflow/home.py +0 -8
@@ 1,8 0,0 @@
from _models import Command, Project

project = Project("/home/kvikshaug", [
    Command("cp", [
        "git ci -m updates",
        "git push -f",
    ]),
])

D .workflow/kvikshaug.py => .workflow/kvikshaug.py +0 -32
@@ 1,32 0,0 @@
from _models import Command, Project

project = Project("code/kvikshaug.no", [
    Command("build", [
        "wf sass build",
        "wf babel build",
    ]),
    Command("sass build", ["docker-compose run --rm sass sass -s compressed assets/sass:assets/dist/css"]),
    Command("babel build", ["docker-compose run --rm babel babel --verbose js -d assets/dist/js"]),

    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py kvikshaug.app:app"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),

    Command("deploy", ["ssh brillig ./services/kvikshaug.no/deploy.sh"]),
])

D .workflow/p2pool.py => .workflow/p2pool.py +0 -7
@@ 1,7 0,0 @@
from _models import Command, Project

project = Project("code/p2pool", [
    Command("clean", [
        "rm -rf p2pool pkg src"
    ]),
])

D .workflow/tv.py => .workflow/tv.py +0 -10
@@ 1,10 0,0 @@
from _models import Command, Project

project = Project("code/tv", [
    Command("qa", [
        "black --check src tests",
        "flake8 src tests",
        "isort --recursive --check-only src tests",
    ]),
    Command("format", ["black src tests", "isort --recursive src tests",]),
])

D .workflow/unseenbio-metrics.py => .workflow/unseenbio-metrics.py +0 -27
@@ 1,27 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/metrics", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", ["docker compose run --rm web pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["docker compose run --rm web pip-compile --generate-hashes --upgrade"]),
    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --verbosity 1 --durations=5 --cov=src"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py metrics.app:app"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("deploy", ["ssh marvin ./scripts/deploy-metrics.sh"]),
])

D .workflow/unseenbio-myub.py => .workflow/unseenbio-myub.py +0 -71
@@ 1,71 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/myub", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", ["docker compose run --rm web pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["docker compose run --rm web pip-compile --generate-hashes --upgrade"]),
    Command("sass build", ["sass -s compressed static/sass:static/css"]),
    Command("sass watch", ["sass --watch -s compressed static/sass:static/css"]),
    Command("i18n external", ["docker compose run --rm web python translations/external/extract.py"]),
    Command("i18n extract", [
        "docker compose run --rm web pybabel extract --no-wrap -F babel.cfg -c 'i18n:' -o translations/messages.pot .",
        "docker compose run --rm web pybabel update --no-wrap --ignore-obsolete -i translations/messages.pot -d translations",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("i18n compile", ["docker compose run --rm web pybabel compile -d translations"]),
    Command("terms cp", [
        "cp ../terms-of-service/source/terms.html ./templates/terms/en.html",
        "cp ../terms-of-service/translations/da.html ./templates/terms/da.html",
        "cp ../terms-of-service/translations/de.html ./templates/terms/de.html",
    ]),
    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --verbosity 1 --durations=5 --cov=src"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py myub.app:app"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("create-superuser", ["docker compose run --rm web flask create-superuser"]),
    Command("deploy master", ["ssh marvin ./scripts/deploy-myub.sh"]),
    Command("deploy staging", ["ssh marvin ./scripts/deploy-myub-staging.sh"]),
    Command("mpd master", [
        "git co master",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy master",
    ]),
    Command("mpd staging", [
        "git co staging",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy staging",
    ]),
    Command("mpd translations", [
        "git co translations",
        "git merge -",
        "git push",
        "git co -",
    ]),
    Command("datamigrate", [
        "scp datamigration.py marvin:services/myub",
        "ssh marvin ./scripts/migrate-myub.sh",
    ]),
    Command("datamigrate staging", [
        "scp datamigration.py marvin:services/myub-staging",
        "ssh marvin ./scripts/migrate-myub-staging.sh",
    ]),
])

D .workflow/unseenbio-oesd-backend.py => .workflow/unseenbio-oesd-backend.py +0 -26
@@ 1,26 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/oesd-backend", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", ["pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["pip-compile --generate-hashes --upgrade"]),
    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py oesd.app:app"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("deploy", ["ssh marvin ./scripts/deploy-oesd-backend.sh"]),
])

D .workflow/unseenbio-oesd-frontend.py => .workflow/unseenbio-oesd-frontend.py +0 -10
@@ 1,10 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/oesd-frontend", [
    Command("serve", ["npx vue-cli-service serve"]),
    Command("lint", ["npx vue-cli-service lint --no-fix --max-warnings 0"]),
    Command("format", ["npx vue-cli-service lint"]),
    Command("test", ["npx vue-cli-service test:unit"]),
    Command("build", ["npx vue-cli-service build"]),
    Command("deploy", ["scp -r dist marvin:services/oesd-frontend/"]),
])

D .workflow/unseenbio-terms-of-service.py => .workflow/unseenbio-terms-of-service.py +0 -30
@@ 1,30 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/terms-of-service", [
    Command("markdown", [
        "python -m markdown2 --extras break-on-newline,code-friendly,header-ids source/terms.md > html/en.html",
    ]),
    Command("i18n extract", [
        "html2po -P html/en.html -o translations/messages.pot",
        # Note: Could maybe use `pot2po` + `pomerge` here, but `pybabel` does the trick.
        "pybabel update --no-wrap --ignore-obsolete -l da -i translations/messages.pot -o 'translations/da.po'",
        "pybabel update --no-wrap --ignore-obsolete -l de -i translations/messages.pot -o 'translations/de.po'",
        # "pot2po -t html -i translations/messages.pot -o translations/da.po",
        # "pot2po -t html -i translations/messages.pot -o translations/de.po",
    ]),
    Command("i18n write", [
        "po2html -t html/en.html -i translations/da.po -o html/da.html",
        "po2html -t html/en.html -i translations/de.po -o html/de.html",
    ]),
    Command("terms cp", [
        "cp html/en.html ../myub/templates/terms/en.html",
        "cp html/da.html ../myub/templates/terms/da.html",
        "cp html/de.html ../myub/templates/terms/de.html",
    ]),
    Command("mpd translations", [
        "git co translations",
        "git merge -",
        "git push",
        "git co -",
    ]),
])

D .workflow/unseenbio-ubdb.py => .workflow/unseenbio-ubdb.py +0 -79
@@ 1,79 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/ubdb", [
    Command("pip-compile", ["docker compose run --rm web pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["docker compose run --rm web pip-compile --generate-hashes --upgrade"]),
    Command("createdb", [
        "docker compose exec ubdb psql -U postgres -c 'create database unseen'",
        "docker compose exec ubdb psql -U postgres -c 'create database testing'",
    ]),
    Command("importroles", ["ssh marvin docker-compose -f services/ubdb/docker-compose.production.yml exec -T ubdb pg_dumpall --roles-only -U postgres | docker compose exec -T ubdb psql -U postgres"]),
    Command("importdb", [
        "docker compose exec ubdb psql -U postgres -c 'drop database unseen;'",
        "docker compose exec ubdb psql -U postgres -c 'create database unseen;'",
        "ssh marvin docker-compose -f services/ubdb/docker-compose.production.yml exec -T ubdb pg_dump -U postgres -Fc unseen | docker-compose exec -T ubdb pg_restore -U postgres -d unseen",
        # Workaround, seems it's not needed anymore:
        # "ssh marvin docker-compose -f services/ubdb/docker-compose.production.yml exec -T ubdb pg_dump -U postgres -Fc unseen > db-tmp",
        # "docker compose cp ./db-tmp ubdb:/",
        # "docker-compose exec -T ubdb pg_restore -U postgres -d unseen /db-tmp",
        # "docker-compose exec -T ubdb rm /db-tmp",
        # "rm db-tmp",
    ]),
    Command("importdb local", [
        "docker compose exec ubdb psql -U postgres -c 'drop database unseen;'",
        "docker compose exec ubdb psql -U postgres -c 'create database unseen;'",
        "cat ubdb.sql | docker-compose exec -T ubdb pg_restore -U postgres -d unseen",
    ]),
    Command("importdb backup", [
        "mcli cp wasabi-2/unseenbio-backups-marvin/$(date +\"%Y-%m-%d\")/ubdb.sql.zst .",
        "unzstd ubdb.sql.zst",
        "docker compose exec ubdb psql -U postgres -c 'drop database unseen;'",
        "docker compose exec ubdb psql -U postgres -c 'create database unseen;'",
        "cat ubdb.sql | docker compose exec -T ubdb psql -U postgres -d unseen",
    ]),
    Command("migrate", [
        "docker compose run --rm web flask db migrate",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("upgrade", ["docker compose run --rm web flask db upgrade"]),
    Command("testing reset", [
        "docker compose exec ubdb psql -U postgres -c 'drop database testing'",
        "docker compose exec ubdb psql -U postgres -c 'create database testing'",
    ]),
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("psql", ["docker compose run --rm ubdb psql -U postgres -h ubdb"]),
    Command("format", [
        "docker compose run --rm web isort src",
        "docker compose run --rm web black src",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src"]),
    Command("black check", ["docker compose run --rm web black --check src"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("deploy master", ["ssh marvin ./scripts/deploy-ubdb.sh"]),
    Command("deploy staging", ["ssh marvin ./scripts/deploy-ubdb-staging.sh"]),
    Command("marvin staging importdb", ["ssh marvin ./scripts/ubdb-staging-importdb.sh"]),
    Command("marvin staging upgrade", ["ssh marvin ./scripts/ubdb-staging-upgrade.sh"]),
    Command("marvin staging create-superuser", ["ssh marvin ./scripts/ubdb-staging-create-superuser.sh"]),
    Command("mpd master", [
        "git co master",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy master",
    ]),
    Command("mpd staging", [
        "git co staging",
        "git merge -",
        "git push",
        "wf deploy staging",
        "git co -",
    ]),
])

D .workflow/unseenbio-uboms.py => .workflow/unseenbio-uboms.py +0 -50
@@ 1,50 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/uboms", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", ["docker compose run --rm web pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["docker compose run --rm web pip-compile --generate-hashes --upgrade"]),
    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --verbosity 1 --durations=5 --cov=src"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py uboms.app:app"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("deploy master", ["ssh marvin ./scripts/deploy-uboms.sh"]),
    Command("deploy staging", ["ssh marvin ./scripts/deploy-uboms-staging.sh"]),
    Command("mpd master", [
        "git co master",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy master",
    ]),
    Command("mpd staging", [
        "git co staging",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy staging",
    ]),
    Command("datamigrate", [
        "scp datamigration.py marvin:services/uboms",
        "ssh marvin ./scripts/migrate-uboms.sh",
    ]),
    Command("datamigrate staging", [
        "scp datamigration.py marvin:services/uboms-staging",
        "ssh marvin ./scripts/migrate-uboms-staging.sh",
    ]),
])

D .workflow/unseenbio-unseenbio.com.py => .workflow/unseenbio-unseenbio.com.py +0 -62
@@ 1,62 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/unseenbio.com", [
    Command("ipython", ["docker compose run --rm web ipython"]),
    Command("pip-compile", ["pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["pip-compile --generate-hashes --upgrade"]),
    Command("sass build", ["sass -s compressed static/sass:static/css"]),
    Command("sass watch", ["sass --watch -s compressed static/sass:static/css"]),
    Command("i18n extract", [
        "docker compose run --rm web pybabel extract --no-wrap -F babel.cfg -c 'i18n:' -o translations/messages.pot .",
        "docker compose run --rm web pybabel update --no-wrap --ignore-obsolete -i translations/messages.pot -d translations",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("i18n compile", ["docker compose run --rm web pybabel compile -d translations"]),
    Command("dbip extract", ["docker compose run --rm web python data/dbip-extract.py"]),
    Command("terms cp", [
        "cp ../terms-of-service/source/terms.html ./templates/terms/en.html",
        "cp ../terms-of-service/translations/da.html ./templates/terms/da.html",
        "cp ../terms-of-service/translations/de.html ./templates/terms/de.html",
    ]),
    Command("format", [
        "docker compose run --rm web isort src tests",
        "docker compose run --rm web black src tests",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
        "wf gunicorn",
        "wf test",
    ]),
    Command("flake8", ["docker compose run --rm web flake8 src tests"]),
    Command("isort check", ["docker compose run --rm web isort --check-only src tests"]),
    Command("black check", ["docker compose run --rm web black --check src tests"]),
    Command("test", ["docker compose run --rm -e ENVIRONMENT=testing web pytest --durations=5 --cov=src"]),
    Command("gunicorn", ["docker compose run --rm web gunicorn --check-config -c gunicorn.py unseen.app:app"]),
    Command("safety", ["docker compose run --rm web safety check --full-report"]),
    Command("deploy master", ["ssh marvin ./scripts/deploy-unseenbio.com.sh"]),
    Command("deploy staging", ["ssh marvin ./scripts/deploy-unseenbio.com-staging.sh"]),
    Command("mpd master", [
        "git co master",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy master",
    ]),
    Command("mpd staging", [
        "git co staging",
        "git merge -",
        "git push",
        "git co -",
        "wf deploy staging",
    ]),
    Command("mpd translations", [
        "git co translations",
        "git merge -",
        "git push",
        "git co -",
    ]),
])

D .workflow/unseenbio-vacations.py => .workflow/unseenbio-vacations.py +0 -21
@@ 1,21 0,0 @@
from _models import Command, Project

project = Project("code/unseen-bio/vacations", [
    Command("pip-compile", ["pip-compile --generate-hashes"]),
    Command("pip-compile upgrade", ["pip-compile --generate-hashes --upgrade"]),
    Command("format", [
        "isort main.py",
        "black main.py",
        "sudo chown -R kvikshaug:kvikshaug .",
    ]),
    Command("qa", [
        "wf flake8",
        "wf isort check",
        "wf black check",
        "wf safety",
    ]),
    Command("flake8", ["flake8 main.py"]),
    Command("isort check", ["isort --check-only main.py"]),
    Command("black check", ["black --check main.py"]),
    Command("safety", ["safety check --full-report"]),
])

D bin/drive => bin/drive +0 -18
@@ 1,18 0,0 @@
#!/usr/bin/env bash

function mount {
  sshfs brillig:drive ~/drive -C
}

function umount {
  fusermount3 -u ~/drive
}

if [[ $1 == "mount" ]]; then
  mount
elif [[ $1 == "umount" ]]; then
  umount
else
  echo "unknown command"
  exit 1
fi