Commit 068a9c2c authored by Christophe Benz's avatar Christophe Benz

Use higher level environ module

parent f8b7390d
Pipeline #114426 failed with stages
in 3 minutes and 29 seconds
......@@ -48,7 +48,7 @@ import pysolr
import requests
import ujson as json
import validators
from dotenv import load_dotenv
from environs import Env
from gitlab.v4.objects import Project, ProjectJob, ProjectPipelineSchedule
from jinja2 import Environment, FileSystemLoader, select_autoescape
from ruamel.yaml import YAML
......@@ -82,50 +82,53 @@ jinja2_env = Environment(
def main():
load_dotenv()
env = Env()
env.read_env()
parser = argparse.ArgumentParser()
parser.add_argument(
"--gitlab-base-url",
default=os.getenv("GITLAB_BASE_URL", "https://git.nomics.world"),
default=env.str("GITLAB_BASE_URL", "https://git.nomics.world"),
help="base URL of GitLab instance",
)
parser.add_argument(
"--ui-base-url",
default=os.getenv("UI_BASE_URL", "https://db.nomics.world"),
default=env.str("UI_BASE_URL", "https://db.nomics.world"),
help="base URL of DBnomics UI",
)
parser.add_argument(
"--solr-url",
default=os.getenv("SOLR_URL", "http://localhost:8983/solr/dbnomics"),
default=env.str("SOLR_URL", "http://localhost:8983/solr/dbnomics"),
help="base URL of Solr core",
)
parser.add_argument(
"--fetchers-yml",
default=os.getenv("FETCHERS_YML", "fetchers.yml"),
default=env.str("FETCHERS_YML", "fetchers.yml"),
help="path or URL of fetchers.yml",
)
parser.add_argument(
"--all-branches",
action="store_true",
default=env.bool("ALL_BRANCHES", default=False),
help="consider all branches for source-data and json-data jobs, "
"(not only master)",
)
parser.add_argument(
"--no-solr-info",
action="store_true",
default=env.bool("NO_SOLR_INFO", default=False),
help="disable requesting Solr to get additional information",
)
parser.add_argument(
"--nb-data-model-jobs",
type=int,
default=os.getenv("NB_DATA_MODEL_JOBS", 100),
default=env.int("NB_DATA_MODEL_JOBS", 100),
help="how many jobs of {} to load".format(DBNOMICS_DATA_MODEL),
)
parser.add_argument(
"--nb-importer-jobs",
type=int,
default=os.getenv("NB_IMPORTER_JOBS", 100),
default=env.int("NB_IMPORTER_JOBS", 100),
help="how many jobs of {} to load".format(DBNOMICS_IMPORTER),
)
parser.add_argument("--debug", action="store_true", help="display DEBUG logs")
......@@ -339,7 +342,8 @@ class DashboardGenerator:
self.jobs_by_slug = self.cache.get("jobs_by_slug")
self.importer_jobs = self.cache.get("importer_jobs")
self.data_model_jobs = self.cache.get("data_model_jobs")
self.solr_counts_by_slug = self.cache.get("solr_counts_by_slug")
if not args.no_solr_info:
self.solr_counts_by_slug = self.cache.get("solr_counts_by_slug")
self.gl = gitlab.Gitlab(
args.gitlab_base_url,
......
daiquiri
environs
humanfriendly
jinja2
pysolr
python-dotenv
python-gitlab
python-slugify
requests
......
......@@ -8,12 +8,14 @@ certifi==2019.11.28 # via requests
chardet==3.0.4 # via requests
daiquiri==1.6.1
decorator==4.4.1 # via validators
environs==7.1.0
humanfriendly==4.18
idna==2.8 # via requests
jinja2==2.10.3
markupsafe==1.1.1 # via jinja2
marshmallow==3.3.0 # via environs
pysolr==3.8.1
python-dotenv==0.10.3
python-dotenv==0.10.3 # via environs
python-gitlab==1.15.0
python-slugify==4.0.0
requests==2.22.0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment