Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup params #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 55 additions & 62 deletions manuscripts/config.py
Original file line number Diff line number Diff line change
@@ -27,11 +27,12 @@
import logging

from grimoire_elk.utils import get_connectors
from sirmordred.task import Task

logger = logging.getLogger(__name__)


class Config():
class Config:
"""Class aimed to manage mordred configuration"""

def __init__(self, conf_file, conf_list=[]):
@@ -233,6 +234,11 @@ def general_params(cls):
"default": True,
"type": bool
},
"autorefresh_interval": {
"optional": True,
"default": 30,
"type": int
},
"user": optional_string_none,
"password": optional_string_none
}
@@ -249,6 +255,36 @@ def general_params(cls):
"optional": True,
"default": "git",
"type": str
},
"kibiter_url": {
"optional": True,
"default": "git",
"type": str
},
"kibiter_version": {
"optional": True,
"default": "git",
"type": str
},
"community": {
"optional": True,
"default": False,
"type": bool
},
"gitlab-issues": {
"optional": True,
"default": False,
"type": bool
},
"gitlab-merges": {
"optional": True,
"default": False,
"type": bool
},
"kafka": {
"optional": True,
"default": False,
"type": bool
}
}
}
@@ -386,65 +422,8 @@ def general_params(cls):
}
}

params_enrich_onion = {
"enrich_onion": {
"in_index": {
"optional": False,
"default": None,
"type": str
},
"out_index": {
"optional": False,
"default": None,
"type": str
},
"contribs_field": {
"optional": True,
"default": "hash",
"type": str
},
"no_incremental": {
"optional": True,
"default": True,
"type": bool
}
}
}

params_enrich_areas_of_code = {
"enrich_areas_of_code": {
"in_index": {
"optional": False,
"default": None,
"type": str
},
"out_index": {
"optional": False,
"default": None,
"type": str
},
"no_incremental": {
"optional": True,
"default": True,
"type": bool
}
}
}

params_enrich_demography = {
"enrich_demography": {
"no_incremental": {
"optional": True,
"default": True,
"type": bool
}
}
}

tasks_config_params = [params_collection, params_enrichment, params_panels,
params_report, params_sortinghat, params_track_items,
params_enrich_areas_of_code, params_enrich_demography,
params_enrich_onion]
params_report, params_sortinghat, params_track_items]

for section_params in tasks_config_params:
params.update(section_params)
@@ -504,10 +483,19 @@ def get_backend_sections(cls):
# a backend name could include and extra ":<param>"
# to have several backend entries with different configs
gelk_backends = list(get_connectors().keys())
extra_backends = ["apache", "google_hits", "remo:activities"]
extra_backends = ["apache", "google_hits", "remo:activities", "gitlab:issue", "gitlab:merge"]

return gelk_backends + extra_backends

@classmethod
def get_study_sections(cls):
# a study name could include and extra ":<param>"
# to have several backend entries with different configs
studies = ("enrich_demography", "enrich_areas_of_code", "enrich_onion", "kafka_kip",
"enrich_pull_requests")

return studies

@classmethod
def get_global_data_sources(cls):
""" Data sources than are collected and enriched globally """
@@ -529,11 +517,16 @@ def check_config(cls, config):
# First let's check all common sections entries
check_params = cls.general_params()
backend_sections = cls.get_backend_sections()
study_sections = cls.get_study_sections()

for section in config.keys():
if section in backend_sections or section[1:] in backend_sections:
config_sections = [section for section in config.keys() if section.split(":")[0][0] != "*"]

for section in config_sections:
if Task.get_backend(section) in backend_sections:
# backend_section or *backend_section, to be checked later
continue
if section.startswith(study_sections):
continue
if section not in check_params.keys():
raise RuntimeError("Wrong section:", section)
# Check the params for the section
4 changes: 2 additions & 2 deletions manuscripts/metrics/metrics.py
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ def get_metrics_data(self, query):
url = self.es_url
else:
url = 'http://' + self.es_url
es = Elasticsearch(url)
es = Elasticsearch(url, timeout=3600, max_retries=50, retry_on_timeout=True, verify_certs=False)
s = Search(using=es, index=self.es_index)
s = s.update_from_dict(query)
try:
@@ -260,4 +260,4 @@ def get_trend(self):
else:
trend_percentage = int((trend / last) * 100)

return (last, trend_percentage)
return last, trend_percentage