From 533e47fd05f685024083ce7a823e9c26c35dd824 Mon Sep 17 00:00:00 2001 From: Rollie Ma Date: Sun, 5 Dec 2021 12:24:05 -0800 Subject: [PATCH] python: update suggested version to 3.8.12 (#33) --- .github/workflows/ci.yml | 2 +- Makefile | 6 +++--- README.md | 8 ++++---- config/config.go | 2 +- config/config_test.go | 2 +- metric/scheduler.go | 2 ++ model/requirements.txt | 2 ++ prom/exporter.go | 4 +++- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1d186d..a1329f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: go_version: ["1.16.10"] - python_version: ["3.7.12"] + python_version: ["3.8.12"] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index bd36f04..317b168 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ APP := reckon -PYTHON_VERSION := 3.7.12 +PYTHON_VERSION := 3.8.12 GO_VERSION := 1.16.10 GORELEASER_VERSION := 0.174.0 OSX_SDK_VERSION := 11.3 -PORT := 8080:8080 +PORT := 9999:9999 PROM_CLIENT_URL ?= http://prometheus.rpi.topbass.studio:9090 -PROM_EXPORTER_ADDR ?= :8080 +PROM_EXPORTER_ADDR ?= :9999 # comma separated list or inline yaml # WATCH_LIST ?= sensehat_temperature,sensehat_humidity WATCH_LIST ?= {sensehat_temperature: [Prophet, Tangram], sensehat_humidity: [Prophet, Tangram]} diff --git a/README.md b/README.md index ae8c159..248aedb 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ Go, Python and Virtualenv. Make sure you have Go 1.16+ and Python 3.7 - Pyenv: `brew install pyenv` or [follow this guide](https://github.com/pyenv/pyenv#installation) - Python3.7 - find a Python 3.7 version with `pyenv install -l | grep '^\s*3.7'` - - select a version (eg. `3.7.12`) and install it with `pyenv install 3.7.12` - - switch to the installed version `pyenv global 3.7.12` + - select a version (eg. `3.8.12`) and install it with `pyenv install 3.8.12` + - switch to the installed version `pyenv global 3.8.12` - Virtualenvwrapper: `pip install virtualenvwrapper` AND [follow this guide](https://virtualenvwrapper.readthedocs.io/en/latest/install.html) ```shell @@ -95,7 +95,7 @@ Reckon can be configured with the following environment variables: | `TIMEZONE` | Yes | `America/Vancouver` | timezone for calculating schedule | | `WATCH_LIST` | Yes | | metrics to scrape, YAML (model names specified on each metric) or comma separated list (needs `MODELS`) | | `MODELS` | Yes | `Prophet` | ML models for training and forecasting, required if `WATCH_LIST` is a comma separated list | -| `PROM_EXPORTER_ADDR` | Yes | `:8080` | address for reckon to expose forecasted metrics | +| `PROM_EXPORTER_ADDR` | Yes | `:9999` | address for reckon to expose forecasted metrics | | `PROM_CLIENT_URL` | Yes | | reckon will scrape metrics from this URL | | `PROM_CLIENT_TLS_CA` | No | | CA cert if `PROM_CLIENT_URL` is https | | `PROM_CLIENT_TLS_CERT` | No | | TLS cert if `PROM_CLIENT_URL` is https | @@ -163,5 +163,5 @@ Reckon exposes build info through `reckon_build_info` ``` # HELP reckon_build_info Information about reckon build. # TYPE reckon_build_info gauge -reckon_build_info{commit="c5159d0375d59b0255069eeec3fe3d3ccfe42207",date="2021-11-24T08:05:34Z",go_version="1.16.10",goreleaser_version="0.174.0",python_version="3.7.12",version="0.5.2"} 1 +reckon_build_info{commit="c5159d0375d59b0255069eeec3fe3d3ccfe42207",date="2021-11-24T08:05:34Z",go_version="1.16.10",goreleaser_version="0.174.0",python_version="3.8.12",version="0.5.2"} 1 ``` diff --git a/config/config.go b/config/config.go index 6ad20da..0494f23 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,7 @@ type Config struct { Schedule string `envconfig:"SCHEDULE" default:"@every 120m"` Timezone string `envconfig:"TIMEZONE" default:"America/Vancouver"` - PromExporterAddr string `envconfig:"PROM_EXPORTER_ADDR" default:":8080"` + PromExporterAddr string `envconfig:"PROM_EXPORTER_ADDR" default:":9999"` PromClientURL string `envconfig:"PROM_CLIENT_URL"` PromClientTLSCA string `envconfig:"PROM_CLIENT_TLS_CA"` diff --git a/config/config_test.go b/config/config_test.go index adfcb9e..bd29e05 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -41,7 +41,7 @@ func TestConfigLoad(t *testing.T) { // from default values Schedule: "@every 120m", Timezone: "America/Vancouver", - PromExporterAddr: ":8080", + PromExporterAddr: ":9999", Models: []string{"Prophet"}, DefaultChunkSize: 120 * time.Minute, GRPCServerAddress: "localhost:18443", diff --git a/metric/scheduler.go b/metric/scheduler.go index 78d7aea..919e734 100644 --- a/metric/scheduler.go +++ b/metric/scheduler.go @@ -46,6 +46,8 @@ func (s *Scheduler) Start(ctx context.Context) func() error { }() }) }); err != nil { + s.logger.Error("failed to schedule cron job", + zap.String("schedule", s.config.Schedule), zap.Error(err)) return err } diff --git a/model/requirements.txt b/model/requirements.txt index caaded3..7341d93 100644 --- a/model/requirements.txt +++ b/model/requirements.txt @@ -14,6 +14,7 @@ matplotlib==3.4.2 numpy==1.21.0 pandas==1.3.0 Pillow==8.3.2 +plotly==5.4.0 protobuf==3.19.1 PyMeeus==0.5.11 pyparsing==2.4.7 @@ -22,5 +23,6 @@ python-json-logger==2.0.2 pytz==2021.1 setuptools-git==1.2 six==1.16.0 +tenacity==8.0.1 tqdm==4.61.1 ujson==4.0.2 diff --git a/prom/exporter.go b/prom/exporter.go index 3234cf8..1e4463e 100644 --- a/prom/exporter.go +++ b/prom/exporter.go @@ -39,6 +39,7 @@ func (e *Exporter) Start(ctx context.Context) func() error { addrField := zap.String("addr", e.config.PromExporterAddr) e.logger.Info("starting prometheus exporter server...", addrField) if err := e.server.ListenAndServe(); err != http.ErrServerClosed { + e.logger.Error("prometheus exporter server stopped", zap.Error(err)) return fmt.Errorf("prometheus exporter server stopped: %w", err) } e.logger.Info("prometheus exporter server stopped", addrField) @@ -56,7 +57,8 @@ func (e *Exporter) Shutdown(ctx context.Context) func() error { defer cancel() if err := e.server.Shutdown(timeout); err != nil { - err = fmt.Errorf("failed to gracefully stop prometheus exporter server: %w", err) + e.logger.Error("failed to gracefully stop prometheus exporter server", zap.Error(err)) + return fmt.Errorf("failed to gracefully stop prometheus exporter server: %w", err) } return nil }