Donation graph now works in a container

pull/370/head
Christopher Usher 1 year ago
parent 2c8a27330f
commit a6e990db68

@ -32,6 +32,7 @@
tootbot: false, tootbot: false,
twitchbot: false, twitchbot: false,
bus_analyzer: false, bus_analyzer: false,
graphs: false,
}, },
// Twitch channels to capture. The first one will be used as the default channel in the editor. // Twitch channels to capture. The first one will be used as the default channel in the editor.
@ -571,6 +572,14 @@
environment: $.env, environment: $.env,
}, },
[if $.enabled.graphs then "graphs"]: {
image: $.get_image("graphs"),
restart: "always",
command: ["--base-dir", "/mnt/graphs"],
volumes: ["%s:/mnt" % $.segments_path],
environment: $.env,
},
local bot_service(name, config, args, subcommand=null) = { local bot_service(name, config, args, subcommand=null) = {
image: $.get_image("zulip_bots"), image: $.get_image("zulip_bots"),
restart: "always", restart: "always",

@ -2,7 +2,6 @@ import gevent.monkey
gevent.monkey.patch_all() gevent.monkey.patch_all()
import logging import logging
import os
import argh import argh

@ -4,12 +4,14 @@ gevent.monkey.patch_all()
import datetime import datetime
import logging import logging
import json import json
import os
import requests import argh
import bokeh.plotting import bokeh.plotting
import bokeh.models import bokeh.models
import bokeh.palettes import bokeh.palettes
import requests
import numpy as np import numpy as np
@ -54,15 +56,16 @@ def load_previous_donations(start_end_times, timeout):
return all_years, current_year return all_years, current_year
def main(): @argh.arg('--base-dir', help='Directory where segments are stored. Default is current working directory.')
def main(base_dir='.'):
stopping = gevent.event.Event() stopping = gevent.event.Event()
delay = 60 * 1 delay = 60 * 1
timeout = 15 timeout = 15
start_end_file = 'start_end_times.json'
logging.info('Loading start and end times') logging.info('Loading start and end times')
start_end_times = json.load(open(start_end_file)) start_end_path = os.path.join(base_dir, 'start_end_times.json')
start_end_times = json.load(open(start_end_path))
start_end_times = {int(year):start_end_times[year] for year in start_end_times} start_end_times = {int(year):start_end_times[year] for year in start_end_times}
all_years, current_year = load_previous_donations(start_end_times, timeout) all_years, current_year = load_previous_donations(start_end_times, timeout)
@ -106,8 +109,10 @@ def main():
p.legend.location = "top_left" p.legend.location = "top_left"
p.legend.click_policy="hide" p.legend.click_policy="hide"
logging.info('Saving plot') output_path = os.path.join(base_dir, 'all_years_donations.html')
bokeh.plotting.save(p, filename='dbfh_donations.html', title='DBfH Donations') bokeh.plotting.output_file(filename=output_path, title='DBfH All Years Donations')
bokeh.plotting.save(p, filename=output_path)
logging.info('{} Saved'.format(output_path))
except Exception: except Exception:
logging.exception('Plotting failed. Retrying') logging.exception('Plotting failed. Retrying')

@ -11,13 +11,13 @@ cd "$(dirname "$(realpath "$0")")"
# Pass PUSH=true to also push the resulting images, or PUSH=latest to push them as :latest tag # Pass PUSH=true to also push the resulting images, or PUSH=latest to push them as :latest tag
# The different images we can build # The different images we can build
COMPONENTS=(downloader restreamer backfiller thrimshim cutter sheetsync nginx postgres segment_coverage graphs) COMPONENTS=(downloader restreamer backfiller thrimshim cutter sheetsync nginx postgres segment_coverage playlist_manager chat_archiver graphs)
# Define push if not already defined # Define push if not already defined
PUSH=${PUSH:-} PUSH=${PUSH:-}
# Base is the repository namespace information, not including the wubloader-component part. # Base is the repository namespace information, not including the wubloader-component part.
BASE="quay.io/ekimekim" BASE="ghcr.io/dbvideostriketeam"
# The docker image tag, derived from the git commit + whether working tree is clean # The docker image tag, derived from the git commit + whether working tree is clean
TAG=$(./get-build-tag) TAG=$(./get-build-tag)

Loading…
Cancel
Save