repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
chaoss/grimoirelab-elk | grimoire_elk/enriched/jenkins.py | JenkinsEnrich.get_fields_from_job_name | def get_fields_from_job_name(self, job_name):
"""Analyze a Jenkins job name, producing a dictionary
The produced dictionary will include information about the category
and subcategory of the job name, and any extra information which
could be useful.
For each deployment of a Jen... | python | def get_fields_from_job_name(self, job_name):
"""Analyze a Jenkins job name, producing a dictionary
The produced dictionary will include information about the category
and subcategory of the job name, and any extra information which
could be useful.
For each deployment of a Jen... | Analyze a Jenkins job name, producing a dictionary
The produced dictionary will include information about the category
and subcategory of the job name, and any extra information which
could be useful.
For each deployment of a Jenkins dashboard, an implementation of
this functio... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/jenkins.py#L122-L174 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/jenkins.py | JenkinsEnrich.extract_builton | def extract_builton(self, built_on, regex):
"""Extracts node name using a regular expression. Node name is expected to
be group 1.
"""
pattern = re.compile(regex, re.M | re.I)
match = pattern.search(built_on)
if match and len(match.groups()) >= 1:
node_name = ... | python | def extract_builton(self, built_on, regex):
"""Extracts node name using a regular expression. Node name is expected to
be group 1.
"""
pattern = re.compile(regex, re.M | re.I)
match = pattern.search(built_on)
if match and len(match.groups()) >= 1:
node_name = ... | Extracts node name using a regular expression. Node name is expected to
be group 1. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/jenkins.py#L176-L189 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/finosmeetings.py | FinosMeetingsEnrich.get_identities | def get_identities(self, item):
""" Return the identities from an item """
data = item['data']
identity = self.get_sh_identity(data)
if identity['username']:
self.add_sh_github_identity(identity['username'])
yield identity | python | def get_identities(self, item):
""" Return the identities from an item """
data = item['data']
identity = self.get_sh_identity(data)
if identity['username']:
self.add_sh_github_identity(identity['username'])
yield identity | Return the identities from an item | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/finosmeetings.py#L91-L100 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | onion_study | def onion_study(in_conn, out_conn, data_source):
"""Build and index for onion from a given Git index.
:param in_conn: ESPandasConnector to read from.
:param out_conn: ESPandasConnector to write to.
:param data_source: name of the date source to generate onion from.
:return: number of documents writ... | python | def onion_study(in_conn, out_conn, data_source):
"""Build and index for onion from a given Git index.
:param in_conn: ESPandasConnector to read from.
:param out_conn: ESPandasConnector to write to.
:param data_source: name of the date source to generate onion from.
:return: number of documents writ... | Build and index for onion from a given Git index.
:param in_conn: ESPandasConnector to read from.
:param out_conn: ESPandasConnector to write to.
:param data_source: name of the date source to generate onion from.
:return: number of documents written in ElasticSearch enriched index. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L371-L381 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | ESOnionConnector.read_block | def read_block(self, size=None, from_date=None):
"""Read author commits by Quarter, Org and Project.
:param from_date: not used here. Incremental mode not supported yet.
:param size: not used here.
:return: DataFrame with commit count per author, split by quarter, org and project.
... | python | def read_block(self, size=None, from_date=None):
"""Read author commits by Quarter, Org and Project.
:param from_date: not used here. Incremental mode not supported yet.
:param size: not used here.
:return: DataFrame with commit count per author, split by quarter, org and project.
... | Read author commits by Quarter, Org and Project.
:param from_date: not used here. Incremental mode not supported yet.
:param size: not used here.
:return: DataFrame with commit count per author, split by quarter, org and project. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L72-L131 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | ESOnionConnector.write | def write(self, items):
"""Write items into ElasticSearch.
:param items: Pandas DataFrame
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
if len(items) == 0:
logger.info(self.__log_prefix + " Nothing to write")
... | python | def write(self, items):
"""Write items into ElasticSearch.
:param items: Pandas DataFrame
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
if len(items) == 0:
logger.info(self.__log_prefix + " Nothing to write")
... | Write items into ElasticSearch.
:param items: Pandas DataFrame | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L133-L180 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | ESOnionConnector.__quarters | def __quarters(self, from_date=None):
"""Get a set of quarters with available items from a given index date.
:param from_date:
:return: list of `pandas.Period` corresponding to quarters
"""
s = Search(using=self._es_conn, index=self._es_index)
if from_date:
#... | python | def __quarters(self, from_date=None):
"""Get a set of quarters with available items from a given index date.
:param from_date:
:return: list of `pandas.Period` corresponding to quarters
"""
s = Search(using=self._es_conn, index=self._es_index)
if from_date:
#... | Get a set of quarters with available items from a given index date.
:param from_date:
:return: list of `pandas.Period` corresponding to quarters | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L214-L239 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | ESOnionConnector.__list_uniques | def __list_uniques(self, date_range, field_name):
"""Retrieve a list of unique values in a given field within a date range.
:param date_range:
:param field_name:
:return: list of unique values.
"""
# Get project list
s = Search(using=self._es_conn, index=self._e... | python | def __list_uniques(self, date_range, field_name):
"""Retrieve a list of unique values in a given field within a date range.
:param date_range:
:param field_name:
:return: list of unique values.
"""
# Get project list
s = Search(using=self._es_conn, index=self._e... | Retrieve a list of unique values in a given field within a date range.
:param date_range:
:param field_name:
:return: list of unique values. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L241-L259 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | ESOnionConnector.__build_dataframe | def __build_dataframe(self, timing, project_name=None, org_name=None):
"""Build a DataFrame from a time bucket.
:param timing:
:param project_name:
:param org_name:
:return:
"""
date_list = []
uuid_list = []
name_list = []
contribs_list = ... | python | def __build_dataframe(self, timing, project_name=None, org_name=None):
"""Build a DataFrame from a time bucket.
:param timing:
:param project_name:
:param org_name:
:return:
"""
date_list = []
uuid_list = []
name_list = []
contribs_list = ... | Build a DataFrame from a time bucket.
:param timing:
:param project_name:
:param org_name:
:return: | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L285-L326 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_onion.py | OnionStudy.process | def process(self, items_block):
"""Process a DataFrame to compute Onion.
:param items_block: items to be processed. Expects to find a pandas DataFrame.
"""
logger.info(self.__log_prefix + " Authors to process: " + str(len(items_block)))
onion_enrich = Onion(items_block)
... | python | def process(self, items_block):
"""Process a DataFrame to compute Onion.
:param items_block: items to be processed. Expects to find a pandas DataFrame.
"""
logger.info(self.__log_prefix + " Authors to process: " + str(len(items_block)))
onion_enrich = Onion(items_block)
... | Process a DataFrame to compute Onion.
:param items_block: items to be processed. Expects to find a pandas DataFrame. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_onion.py#L346-L368 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/projects.py | GrimoireLibProjects.get_projects | def get_projects(self):
""" Get the projects list from database """
repos_list = []
gerrit_projects_db = self.projects_db
db = Database(user="root", passwd="", host="localhost", port=3306,
scrdb=None, shdb=gerrit_projects_db, prjdb=None)
sql = """
... | python | def get_projects(self):
""" Get the projects list from database """
repos_list = []
gerrit_projects_db = self.projects_db
db = Database(user="root", passwd="", host="localhost", port=3306,
scrdb=None, shdb=gerrit_projects_db, prjdb=None)
sql = """
... | Get the projects list from database | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/projects.py#L37-L62 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | metadata | def metadata(func):
"""Add metadata to an item.
Decorator that adds metadata to a given item such as
the gelk revision used.
"""
@functools.wraps(func)
def decorator(self, *args, **kwargs):
eitem = func(self, *args, **kwargs)
metadata = {
'metadata__gelk_version': s... | python | def metadata(func):
"""Add metadata to an item.
Decorator that adds metadata to a given item such as
the gelk revision used.
"""
@functools.wraps(func)
def decorator(self, *args, **kwargs):
eitem = func(self, *args, **kwargs)
metadata = {
'metadata__gelk_version': s... | Add metadata to an item.
Decorator that adds metadata to a given item such as
the gelk revision used. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L78-L95 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.__convert_json_to_projects_map | def __convert_json_to_projects_map(self, json):
""" Convert JSON format to the projects map format
map[ds][repository] = project
If a repository is in several projects assign to leaf
Check that all JSON data is in the database
:param json: data with the projects to repositories ... | python | def __convert_json_to_projects_map(self, json):
""" Convert JSON format to the projects map format
map[ds][repository] = project
If a repository is in several projects assign to leaf
Check that all JSON data is in the database
:param json: data with the projects to repositories ... | Convert JSON format to the projects map format
map[ds][repository] = project
If a repository is in several projects assign to leaf
Check that all JSON data is in the database
:param json: data with the projects to repositories mapping
:returns: the repositories to projects mappi... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L198-L227 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.enrich_items | def enrich_items(self, ocean_backend, events=False):
"""
Enrich the items fetched from ocean_backend generator
generating enriched items/events which are uploaded to the Elasticsearch index for
this Enricher (self).
:param ocean_backend: Ocean backend object to fetch the items f... | python | def enrich_items(self, ocean_backend, events=False):
"""
Enrich the items fetched from ocean_backend generator
generating enriched items/events which are uploaded to the Elasticsearch index for
this Enricher (self).
:param ocean_backend: Ocean backend object to fetch the items f... | Enrich the items fetched from ocean_backend generator
generating enriched items/events which are uploaded to the Elasticsearch index for
this Enricher (self).
:param ocean_backend: Ocean backend object to fetch the items from
:param events: enrich items or enrich events
:return:... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L333-L393 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_grimoire_fields | def get_grimoire_fields(self, creation_date, item_name):
""" Return common grimoire fields for all data sources """
grimoire_date = None
try:
grimoire_date = str_to_datetime(creation_date).isoformat()
except Exception as ex:
pass
name = "is_" + self.get_... | python | def get_grimoire_fields(self, creation_date, item_name):
""" Return common grimoire fields for all data sources """
grimoire_date = None
try:
grimoire_date = str_to_datetime(creation_date).isoformat()
except Exception as ex:
pass
name = "is_" + self.get_... | Return common grimoire fields for all data sources | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L489-L503 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.add_project_levels | def add_project_levels(cls, project):
""" Add project sub levels extra items """
eitem_path = ''
eitem_project_levels = {}
if project is not None:
subprojects = project.split('.')
for i in range(0, len(subprojects)):
if i > 0:
... | python | def add_project_levels(cls, project):
""" Add project sub levels extra items """
eitem_path = ''
eitem_project_levels = {}
if project is not None:
subprojects = project.split('.')
for i in range(0, len(subprojects)):
if i > 0:
... | Add project sub levels extra items | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L515-L529 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.find_item_project | def find_item_project(self, eitem):
"""
Find the project for a enriched item
:param eitem: enriched item for which to find the project
:return: the project entry (a dictionary)
"""
# get the data source name relying on the cfg section name, if null use the connector name
... | python | def find_item_project(self, eitem):
"""
Find the project for a enriched item
:param eitem: enriched item for which to find the project
:return: the project entry (a dictionary)
"""
# get the data source name relying on the cfg section name, if null use the connector name
... | Find the project for a enriched item
:param eitem: enriched item for which to find the project
:return: the project entry (a dictionary) | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L531-L584 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_item_project | def get_item_project(self, eitem):
"""
Get the project name related to the eitem
:param eitem: enriched item for which to find the project
:return: a dictionary with the project data
"""
eitem_project = {}
project = self.find_item_project(eitem)
if projec... | python | def get_item_project(self, eitem):
"""
Get the project name related to the eitem
:param eitem: enriched item for which to find the project
:return: a dictionary with the project data
"""
eitem_project = {}
project = self.find_item_project(eitem)
if projec... | Get the project name related to the eitem
:param eitem: enriched item for which to find the project
:return: a dictionary with the project data | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L586-L605 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_item_metadata | def get_item_metadata(self, eitem):
"""
In the projects.json file, inside each project, there is a field called "meta" which has a
dictionary with fields to be added to the enriched items for this project.
This fields must be added with the prefix cm_ (custom metadata).
This me... | python | def get_item_metadata(self, eitem):
"""
In the projects.json file, inside each project, there is a field called "meta" which has a
dictionary with fields to be added to the enriched items for this project.
This fields must be added with the prefix cm_ (custom metadata).
This me... | In the projects.json file, inside each project, there is a field called "meta" which has a
dictionary with fields to be added to the enriched items for this project.
This fields must be added with the prefix cm_ (custom metadata).
This method fetch the metadata fields for the project in which ... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L607-L630 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_domain | def get_domain(self, identity):
""" Get the domain from a SH identity """
domain = None
if identity['email']:
try:
domain = identity['email'].split("@")[1]
except IndexError:
# logger.warning("Bad email format: %s" % (identity['email']))
... | python | def get_domain(self, identity):
""" Get the domain from a SH identity """
domain = None
if identity['email']:
try:
domain = identity['email'].split("@")[1]
except IndexError:
# logger.warning("Bad email format: %s" % (identity['email']))
... | Get the domain from a SH identity | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L640-L649 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_enrollment | def get_enrollment(self, uuid, item_date):
""" Get the enrollment for the uuid when the item was done """
# item_date must be offset-naive (utc)
if item_date and item_date.tzinfo:
item_date = (item_date - item_date.utcoffset()).replace(tzinfo=None)
enrollments = self.get_enr... | python | def get_enrollment(self, uuid, item_date):
""" Get the enrollment for the uuid when the item was done """
# item_date must be offset-naive (utc)
if item_date and item_date.tzinfo:
item_date = (item_date - item_date.utcoffset()).replace(tzinfo=None)
enrollments = self.get_enr... | Get the enrollment for the uuid when the item was done | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L658-L674 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.__get_item_sh_fields_empty | def __get_item_sh_fields_empty(self, rol, undefined=False):
""" Return a SH identity with all fields to empty_field """
# If empty_field is None, the fields do not appear in index patterns
empty_field = '' if not undefined else '-- UNDEFINED --'
return {
rol + "_id": empty_fi... | python | def __get_item_sh_fields_empty(self, rol, undefined=False):
""" Return a SH identity with all fields to empty_field """
# If empty_field is None, the fields do not appear in index patterns
empty_field = '' if not undefined else '-- UNDEFINED --'
return {
rol + "_id": empty_fi... | Return a SH identity with all fields to empty_field | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L676-L690 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_item_sh_fields | def get_item_sh_fields(self, identity=None, item_date=None, sh_id=None,
rol='author'):
""" Get standard SH fields from a SH identity """
eitem_sh = self.__get_item_sh_fields_empty(rol)
if identity:
# Use the identity to get the SortingHat identity
... | python | def get_item_sh_fields(self, identity=None, item_date=None, sh_id=None,
rol='author'):
""" Get standard SH fields from a SH identity """
eitem_sh = self.__get_item_sh_fields_empty(rol)
if identity:
# Use the identity to get the SortingHat identity
... | Get standard SH fields from a SH identity | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L692-L741 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_item_sh | def get_item_sh(self, item, roles=None, date_field=None):
"""
Add sorting hat enrichment fields for different roles
If there are no roles, just add the author fields.
"""
eitem_sh = {} # Item enriched
author_field = self.get_field_author()
if not roles:
... | python | def get_item_sh(self, item, roles=None, date_field=None):
"""
Add sorting hat enrichment fields for different roles
If there are no roles, just add the author fields.
"""
eitem_sh = {} # Item enriched
author_field = self.get_field_author()
if not roles:
... | Add sorting hat enrichment fields for different roles
If there are no roles, just add the author fields. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L801-L852 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.get_sh_ids | def get_sh_ids(self, identity, backend_name):
""" Return the Sorting Hat id and uuid for an identity """
# Convert the dict to tuple so it is hashable
identity_tuple = tuple(identity.items())
sh_ids = self.__get_sh_ids_cache(identity_tuple, backend_name)
return sh_ids | python | def get_sh_ids(self, identity, backend_name):
""" Return the Sorting Hat id and uuid for an identity """
# Convert the dict to tuple so it is hashable
identity_tuple = tuple(identity.items())
sh_ids = self.__get_sh_ids_cache(identity_tuple, backend_name)
return sh_ids | Return the Sorting Hat id and uuid for an identity | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L867-L872 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.enrich_demography | def enrich_demography(self, ocean_backend, enrich_backend, date_field="grimoire_creation_date",
author_field="author_uuid"):
"""
The goal of the algorithm is to add to all enriched items the first and last date
(i.e., demography_min_date, demography_max_date) of the aut... | python | def enrich_demography(self, ocean_backend, enrich_backend, date_field="grimoire_creation_date",
author_field="author_uuid"):
"""
The goal of the algorithm is to add to all enriched items the first and last date
(i.e., demography_min_date, demography_max_date) of the aut... | The goal of the algorithm is to add to all enriched items the first and last date
(i.e., demography_min_date, demography_max_date) of the author activities.
In order to implement the algorithm first, the min and max dates (based on the date_field attribute)
are retrieved for all authors. Then, ... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L980-L1038 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | Enrich.update_author_min_max_date | def update_author_min_max_date(min_date, max_date, target_author, author_field="author_uuid"):
"""
Get the query to update demography_min_date and demography_max_date of a given author
:param min_date: new demography_min_date
:param max_date: new demography_max_date
:param targe... | python | def update_author_min_max_date(min_date, max_date, target_author, author_field="author_uuid"):
"""
Get the query to update demography_min_date and demography_max_date of a given author
:param min_date: new demography_min_date
:param max_date: new demography_max_date
:param targe... | Get the query to update demography_min_date and demography_max_date of a given author
:param min_date: new demography_min_date
:param max_date: new demography_max_date
:param target_author: target author to be updated
:param author_field: author field
:return: the query to be e... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L1083-L1114 |
chaoss/grimoirelab-elk | utils/gh2arthur.py | get_params_parser | def get_params_parser():
"""Parse command line arguments"""
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--elastic_url", default="http://127.0.0.1:9200",
help="Host with elastic search (default: http://127.0.0.1:9200)")
parser.add_argument('-g', '--debug', dest... | python | def get_params_parser():
"""Parse command line arguments"""
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--elastic_url", default="http://127.0.0.1:9200",
help="Host with elastic search (default: http://127.0.0.1:9200)")
parser.add_argument('-g', '--debug', dest... | Parse command line arguments | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/gh2arthur.py#L49-L64 |
chaoss/grimoirelab-elk | grimoire_elk/elastic_items.py | ElasticItems.get_repository_filter_raw | def get_repository_filter_raw(self, term=False):
""" Returns the filter to be used in queries in a repository items """
perceval_backend_name = self.get_connector_name()
filter_ = get_repository_filter(self.perceval_backend, perceval_backend_name, term)
return filter_ | python | def get_repository_filter_raw(self, term=False):
""" Returns the filter to be used in queries in a repository items """
perceval_backend_name = self.get_connector_name()
filter_ = get_repository_filter(self.perceval_backend, perceval_backend_name, term)
return filter_ | Returns the filter to be used in queries in a repository items | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elastic_items.py#L67-L71 |
chaoss/grimoirelab-elk | grimoire_elk/elastic_items.py | ElasticItems.set_filter_raw | def set_filter_raw(self, filter_raw):
"""Filter to be used when getting items from Ocean index"""
self.filter_raw = filter_raw
self.filter_raw_dict = []
splitted = re.compile(FILTER_SEPARATOR).split(filter_raw)
for fltr_raw in splitted:
fltr = self.__process_filter(... | python | def set_filter_raw(self, filter_raw):
"""Filter to be used when getting items from Ocean index"""
self.filter_raw = filter_raw
self.filter_raw_dict = []
splitted = re.compile(FILTER_SEPARATOR).split(filter_raw)
for fltr_raw in splitted:
fltr = self.__process_filter(... | Filter to be used when getting items from Ocean index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elastic_items.py#L104-L114 |
chaoss/grimoirelab-elk | grimoire_elk/elastic_items.py | ElasticItems.set_filter_raw_should | def set_filter_raw_should(self, filter_raw_should):
"""Bool filter should to be used when getting items from Ocean index"""
self.filter_raw_should = filter_raw_should
self.filter_raw_should_dict = []
splitted = re.compile(FILTER_SEPARATOR).split(filter_raw_should)
for fltr_raw ... | python | def set_filter_raw_should(self, filter_raw_should):
"""Bool filter should to be used when getting items from Ocean index"""
self.filter_raw_should = filter_raw_should
self.filter_raw_should_dict = []
splitted = re.compile(FILTER_SEPARATOR).split(filter_raw_should)
for fltr_raw ... | Bool filter should to be used when getting items from Ocean index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elastic_items.py#L116-L126 |
chaoss/grimoirelab-elk | grimoire_elk/elastic_items.py | ElasticItems.fetch | def fetch(self, _filter=None, ignore_incremental=False):
""" Fetch the items from raw or enriched index. An optional _filter
could be provided to filter the data collected """
logger.debug("Creating a elastic items generator.")
scroll_id = None
page = self.get_elastic_items(scr... | python | def fetch(self, _filter=None, ignore_incremental=False):
""" Fetch the items from raw or enriched index. An optional _filter
could be provided to filter the data collected """
logger.debug("Creating a elastic items generator.")
scroll_id = None
page = self.get_elastic_items(scr... | Fetch the items from raw or enriched index. An optional _filter
could be provided to filter the data collected | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elastic_items.py#L140-L174 |
chaoss/grimoirelab-elk | grimoire_elk/elastic_items.py | ElasticItems.get_elastic_items | def get_elastic_items(self, elastic_scroll_id=None, _filter=None, ignore_incremental=False):
""" Get the items from the index related to the backend applying and
optional _filter if provided"""
headers = {"Content-Type": "application/json"}
if not self.elastic:
return None
... | python | def get_elastic_items(self, elastic_scroll_id=None, _filter=None, ignore_incremental=False):
""" Get the items from the index related to the backend applying and
optional _filter if provided"""
headers = {"Content-Type": "application/json"}
if not self.elastic:
return None
... | Get the items from the index related to the backend applying and
optional _filter if provided | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elastic_items.py#L176-L297 |
chaoss/grimoirelab-elk | utils/index_mapping.py | find_uuid | def find_uuid(es_url, index):
""" Find the unique identifier field for a given index """
uid_field = None
# Get the first item to detect the data source and raw/enriched type
res = requests.get('%s/%s/_search?size=1' % (es_url, index))
first_item = res.json()['hits']['hits'][0]['_source']
fiel... | python | def find_uuid(es_url, index):
""" Find the unique identifier field for a given index """
uid_field = None
# Get the first item to detect the data source and raw/enriched type
res = requests.get('%s/%s/_search?size=1' % (es_url, index))
first_item = res.json()['hits']['hits'][0]['_source']
fiel... | Find the unique identifier field for a given index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L62-L89 |
chaoss/grimoirelab-elk | utils/index_mapping.py | find_mapping | def find_mapping(es_url, index):
""" Find the mapping given an index """
mapping = None
backend = find_perceval_backend(es_url, index)
if backend:
mapping = backend.get_elastic_mappings()
if mapping:
logging.debug("MAPPING FOUND:\n%s", json.dumps(json.loads(mapping['items']), ind... | python | def find_mapping(es_url, index):
""" Find the mapping given an index """
mapping = None
backend = find_perceval_backend(es_url, index)
if backend:
mapping = backend.get_elastic_mappings()
if mapping:
logging.debug("MAPPING FOUND:\n%s", json.dumps(json.loads(mapping['items']), ind... | Find the mapping given an index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L130-L142 |
chaoss/grimoirelab-elk | utils/index_mapping.py | get_elastic_items | def get_elastic_items(elastic, elastic_scroll_id=None, limit=None):
""" Get the items from the index """
scroll_size = limit
if not limit:
scroll_size = DEFAULT_LIMIT
if not elastic:
return None
url = elastic.index_url
max_process_items_pack_time = "5m" # 10 minutes
url +... | python | def get_elastic_items(elastic, elastic_scroll_id=None, limit=None):
""" Get the items from the index """
scroll_size = limit
if not limit:
scroll_size = DEFAULT_LIMIT
if not elastic:
return None
url = elastic.index_url
max_process_items_pack_time = "5m" # 10 minutes
url +... | Get the items from the index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L145-L190 |
chaoss/grimoirelab-elk | utils/index_mapping.py | get_elastic_items_search | def get_elastic_items_search(elastic, search_after=None, size=None):
""" Get the items from the index using search after scrolling """
if not size:
size = DEFAULT_LIMIT
url = elastic.index_url + "/_search"
search_after_query = ''
if search_after:
logging.debug("Search after: %s",... | python | def get_elastic_items_search(elastic, search_after=None, size=None):
""" Get the items from the index using search after scrolling """
if not size:
size = DEFAULT_LIMIT
url = elastic.index_url + "/_search"
search_after_query = ''
if search_after:
logging.debug("Search after: %s",... | Get the items from the index using search after scrolling | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L216-L257 |
chaoss/grimoirelab-elk | utils/index_mapping.py | fetch | def fetch(elastic, backend, limit=None, search_after_value=None, scroll=True):
""" Fetch the items from raw or enriched index """
logging.debug("Creating a elastic items generator.")
elastic_scroll_id = None
search_after = search_after_value
while True:
if scroll:
rjson = get_... | python | def fetch(elastic, backend, limit=None, search_after_value=None, scroll=True):
""" Fetch the items from raw or enriched index """
logging.debug("Creating a elastic items generator.")
elastic_scroll_id = None
search_after = search_after_value
while True:
if scroll:
rjson = get_... | Fetch the items from raw or enriched index | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L261-L294 |
chaoss/grimoirelab-elk | utils/index_mapping.py | export_items | def export_items(elastic_url, in_index, out_index, elastic_url_out=None,
search_after=False, search_after_value=None, limit=None,
copy=False):
""" Export items from in_index to out_index using the correct mapping """
if not limit:
limit = DEFAULT_LIMIT
if search_a... | python | def export_items(elastic_url, in_index, out_index, elastic_url_out=None,
search_after=False, search_after_value=None, limit=None,
copy=False):
""" Export items from in_index to out_index using the correct mapping """
if not limit:
limit = DEFAULT_LIMIT
if search_a... | Export items from in_index to out_index using the correct mapping | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L297-L347 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/gerrit.py | GerritEnrich.get_identities | def get_identities(self, item):
"""Return the identities from an item"""
item = item['data']
# Changeset owner
user = item['owner']
identity = self.get_sh_identity(user)
yield identity
# Patchset uploader and author
if 'patchSets' in item:
f... | python | def get_identities(self, item):
"""Return the identities from an item"""
item = item['data']
# Changeset owner
user = item['owner']
identity = self.get_sh_identity(user)
yield identity
# Patchset uploader and author
if 'patchSets' in item:
f... | Return the identities from an item | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/gerrit.py#L105-L137 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/gerrit.py | GerritEnrich._fix_review_dates | def _fix_review_dates(self, item):
"""Convert dates so ES detect them"""
for date_field in ['timestamp', 'createdOn', 'lastUpdated']:
if date_field in item.keys():
date_ts = item[date_field]
item[date_field] = unixtime_to_datetime(date_ts).isoformat()
... | python | def _fix_review_dates(self, item):
"""Convert dates so ES detect them"""
for date_field in ['timestamp', 'createdOn', 'lastUpdated']:
if date_field in item.keys():
date_ts = item[date_field]
item[date_field] = unixtime_to_datetime(date_ts).isoformat()
... | Convert dates so ES detect them | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/gerrit.py#L145-L166 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/bugzilla.py | BugzillaEnrich.get_sh_identity | def get_sh_identity(self, item, identity_field=None):
""" Return a Sorting Hat identity using bugzilla user data """
def fill_list_identity(identity, user_list_data):
""" Fill identity with user data in first item in list """
identity['username'] = user_list_data[0]['__text__']
... | python | def get_sh_identity(self, item, identity_field=None):
""" Return a Sorting Hat identity using bugzilla user data """
def fill_list_identity(identity, user_list_data):
""" Fill identity with user data in first item in list """
identity['username'] = user_list_data[0]['__text__']
... | Return a Sorting Hat identity using bugzilla user data | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/bugzilla.py#L47-L70 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/bugzilla.py | BugzillaEnrich.get_identities | def get_identities(self, item):
"""Return the identities from an item"""
for rol in self.roles:
if rol in item['data']:
user = self.get_sh_identity(item["data"][rol])
yield user
if 'activity' in item["data"]:
for event in item["data"]['ac... | python | def get_identities(self, item):
"""Return the identities from an item"""
for rol in self.roles:
if rol in item['data']:
user = self.get_sh_identity(item["data"][rol])
yield user
if 'activity' in item["data"]:
for event in item["data"]['ac... | Return the identities from an item | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/bugzilla.py#L75-L92 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | CeresBase.analyze | def analyze(self):
"""Populate an enriched index by processing input items in blocks.
:return: total number of out_items written.
"""
from_date = self._out.latest_date()
if from_date:
logger.info("Reading items since " + from_date)
else:
logger.in... | python | def analyze(self):
"""Populate an enriched index by processing input items in blocks.
:return: total number of out_items written.
"""
from_date = self._out.latest_date()
if from_date:
logger.info("Reading items since " + from_date)
else:
logger.in... | Populate an enriched index by processing input items in blocks.
:return: total number of out_items written. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L77-L119 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.read_item | def read_item(self, from_date=None):
"""Read items and return them one by one.
:param from_date: start date for incremental reading.
:return: next single item when any available.
:raises ValueError: `metadata__timestamp` field not found in index
:raises NotFoundError: index not ... | python | def read_item(self, from_date=None):
"""Read items and return them one by one.
:param from_date: start date for incremental reading.
:return: next single item when any available.
:raises ValueError: `metadata__timestamp` field not found in index
:raises NotFoundError: index not ... | Read items and return them one by one.
:param from_date: start date for incremental reading.
:return: next single item when any available.
:raises ValueError: `metadata__timestamp` field not found in index
:raises NotFoundError: index not found in ElasticSearch | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L161-L175 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.read_block | def read_block(self, size, from_date=None):
"""Read items and return them in blocks.
:param from_date: start date for incremental reading.
:param size: block size.
:return: next block of items when any available.
:raises ValueError: `metadata__timestamp` field not found in index... | python | def read_block(self, size, from_date=None):
"""Read items and return them in blocks.
:param from_date: start date for incremental reading.
:param size: block size.
:return: next block of items when any available.
:raises ValueError: `metadata__timestamp` field not found in index... | Read items and return them in blocks.
:param from_date: start date for incremental reading.
:param size: block size.
:return: next block of items when any available.
:raises ValueError: `metadata__timestamp` field not found in index
:raises NotFoundError: index not found in Elas... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L177-L203 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.write | def write(self, items):
"""Upload items to ElasticSearch.
:param items: items to be uploaded.
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
# Uploading info to the new ES
docs = []
for item in items:
... | python | def write(self, items):
"""Upload items to ElasticSearch.
:param items: items to be uploaded.
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
# Uploading info to the new ES
docs = []
for item in items:
... | Upload items to ElasticSearch.
:param items: items to be uploaded. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L205-L225 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.create_index | def create_index(self, mappings_file, delete=True):
"""Create a new index.
:param mappings_file: index mappings to be used.
:param delete: True to delete current index if exists.
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
... | python | def create_index(self, mappings_file, delete=True):
"""Create a new index.
:param mappings_file: index mappings to be used.
:param delete: True to delete current index if exists.
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
... | Create a new index.
:param mappings_file: index mappings to be used.
:param delete: True to delete current index if exists. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L227-L245 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.create_alias | def create_alias(self, alias_name):
"""Creates an alias pointing to the index configured in this connection"""
return self._es_conn.indices.put_alias(index=self._es_index, name=alias_name) | python | def create_alias(self, alias_name):
"""Creates an alias pointing to the index configured in this connection"""
return self._es_conn.indices.put_alias(index=self._es_index, name=alias_name) | Creates an alias pointing to the index configured in this connection | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L292-L295 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector.exists_alias | def exists_alias(self, alias_name, index_name=None):
"""Check whether or not the given alias exists
:return: True if alias already exist"""
return self._es_conn.indices.exists_alias(index=index_name, name=alias_name) | python | def exists_alias(self, alias_name, index_name=None):
"""Check whether or not the given alias exists
:return: True if alias already exist"""
return self._es_conn.indices.exists_alias(index=index_name, name=alias_name) | Check whether or not the given alias exists
:return: True if alias already exist | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L297-L302 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | ESConnector._build_search_query | def _build_search_query(self, from_date):
"""Build an ElasticSearch search query to retrieve items for read methods.
:param from_date: date to start retrieving items from.
:return: JSON query in dict format
"""
sort = [{self._sort_on_field: {"order": "asc"}}]
filters =... | python | def _build_search_query(self, from_date):
"""Build an ElasticSearch search query to retrieve items for read methods.
:param from_date: date to start retrieving items from.
:return: JSON query in dict format
"""
sort = [{self._sort_on_field: {"order": "asc"}}]
filters =... | Build an ElasticSearch search query to retrieve items for read methods.
:param from_date: date to start retrieving items from.
:return: JSON query in dict format | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L304-L330 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/ceres_base.py | SimpleCopy.process | def process(self, items_block):
"""Return items as they come, updating their metadata__enriched_on field.
:param items_block:
:return: hits blocks as they come, updating their metadata__enriched_on field. Namedtuple containing:
- processed: number of processed hits
- out... | python | def process(self, items_block):
"""Return items as they come, updating their metadata__enriched_on field.
:param items_block:
:return: hits blocks as they come, updating their metadata__enriched_on field. Namedtuple containing:
- processed: number of processed hits
- out... | Return items as they come, updating their metadata__enriched_on field.
:param items_block:
:return: hits blocks as they come, updating their metadata__enriched_on field. Namedtuple containing:
- processed: number of processed hits
- out_items: a list containing items ready to be... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L337-L353 |
chaoss/grimoirelab-elk | grimoire_elk/raw/gitlab.py | GitLabOcean.get_arthur_params_from_url | def get_arthur_params_from_url(cls, url):
""" Get the arthur params given a URL for the data source """
params = {}
args = cls.get_perceval_params_from_url(url)
parser = GitLabCommand.setup_cmd_parser()
parsed_args = parser.parse(*args)
params['owner'] = parsed_args.ow... | python | def get_arthur_params_from_url(cls, url):
""" Get the arthur params given a URL for the data source """
params = {}
args = cls.get_perceval_params_from_url(url)
parser = GitLabCommand.setup_cmd_parser()
parsed_args = parser.parse(*args)
params['owner'] = parsed_args.ow... | Get the arthur params given a URL for the data source | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/gitlab.py#L77-L91 |
chaoss/grimoirelab-elk | grimoire_elk/raw/gitlab.py | GitLabOcean.get_perceval_params_from_url | def get_perceval_params_from_url(cls, url):
""" Get the perceval params given a URL for the data source """
params = []
tokens = url.split(' ')
repo = tokens[0]
owner = repo.split('/')[-2]
repository = repo.split('/')[-1]
params.append(owner)
params.app... | python | def get_perceval_params_from_url(cls, url):
""" Get the perceval params given a URL for the data source """
params = []
tokens = url.split(' ')
repo = tokens[0]
owner = repo.split('/')[-2]
repository = repo.split('/')[-1]
params.append(owner)
params.app... | Get the perceval params given a URL for the data source | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/gitlab.py#L94-L110 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/meetup.py | MeetupEnrich.get_identities | def get_identities(self, item):
''' Return the identities from an item '''
item = item['data']
# Creators
if 'event_hosts' in item:
user = self.get_sh_identity(item['event_hosts'][0])
yield user
# rsvps
rsvps = item.get('rsvps', [])
for... | python | def get_identities(self, item):
''' Return the identities from an item '''
item = item['data']
# Creators
if 'event_hosts' in item:
user = self.get_sh_identity(item['event_hosts'][0])
yield user
# rsvps
rsvps = item.get('rsvps', [])
for... | Return the identities from an item | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/meetup.py#L78-L98 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/meetup.py | MeetupEnrich.get_item_sh | def get_item_sh(self, item):
""" Add sorting hat enrichment fields """
sh_fields = {}
# Not shared common get_item_sh because it is pretty specific
if 'member' in item:
# comment and rsvp
identity = self.get_sh_identity(item['member'])
elif 'event_hosts... | python | def get_item_sh(self, item):
""" Add sorting hat enrichment fields """
sh_fields = {}
# Not shared common get_item_sh because it is pretty specific
if 'member' in item:
# comment and rsvp
identity = self.get_sh_identity(item['member'])
elif 'event_hosts... | Add sorting hat enrichment fields | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/meetup.py#L258-L276 |
chaoss/grimoirelab-elk | grimoire_elk/raw/elastic.py | ElasticOcean.add_params | def add_params(cls, cmdline_parser):
""" Shared params in all backends """
parser = cmdline_parser
parser.add_argument("-e", "--elastic_url", default="http://127.0.0.1:9200",
help="Host with elastic search (default: http://127.0.0.1:9200)")
parser.add_argume... | python | def add_params(cls, cmdline_parser):
""" Shared params in all backends """
parser = cmdline_parser
parser.add_argument("-e", "--elastic_url", default="http://127.0.0.1:9200",
help="Host with elastic search (default: http://127.0.0.1:9200)")
parser.add_argume... | Shared params in all backends | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L47-L55 |
chaoss/grimoirelab-elk | grimoire_elk/raw/elastic.py | ElasticOcean.get_p2o_params_from_url | def get_p2o_params_from_url(cls, url):
""" Get the p2o params given a URL for the data source """
# if the url doesn't contain a filter separator, return it
if PRJ_JSON_FILTER_SEPARATOR not in url:
return {"url": url}
# otherwise, add the url to the params
params = ... | python | def get_p2o_params_from_url(cls, url):
""" Get the p2o params given a URL for the data source """
# if the url doesn't contain a filter separator, return it
if PRJ_JSON_FILTER_SEPARATOR not in url:
return {"url": url}
# otherwise, add the url to the params
params = ... | Get the p2o params given a URL for the data source | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L98-L127 |
chaoss/grimoirelab-elk | grimoire_elk/raw/elastic.py | ElasticOcean.add_update_date | def add_update_date(self, item):
""" All item['updated_on'] from perceval is epoch """
updated = unixtime_to_datetime(item['updated_on'])
timestamp = unixtime_to_datetime(item['timestamp'])
item['metadata__updated_on'] = updated.isoformat()
# Also add timestamp used in incrementa... | python | def add_update_date(self, item):
""" All item['updated_on'] from perceval is epoch """
updated = unixtime_to_datetime(item['updated_on'])
timestamp = unixtime_to_datetime(item['timestamp'])
item['metadata__updated_on'] = updated.isoformat()
# Also add timestamp used in incrementa... | All item['updated_on'] from perceval is epoch | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L147-L153 |
chaoss/grimoirelab-elk | grimoire_elk/raw/elastic.py | ElasticOcean.feed | def feed(self, from_date=None, from_offset=None, category=None,
latest_items=None, arthur_items=None, filter_classified=None):
""" Feed data in Elastic from Perceval or Arthur """
if self.fetch_archive:
items = self.perceval_backend.fetch_from_archive()
self.feed_it... | python | def feed(self, from_date=None, from_offset=None, category=None,
latest_items=None, arthur_items=None, filter_classified=None):
""" Feed data in Elastic from Perceval or Arthur """
if self.fetch_archive:
items = self.perceval_backend.fetch_from_archive()
self.feed_it... | Feed data in Elastic from Perceval or Arthur | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L155-L226 |
chaoss/grimoirelab-elk | grimoire_elk/raw/elastic.py | ElasticOcean._items_to_es | def _items_to_es(self, json_items):
""" Append items JSON to ES (data source state) """
if len(json_items) == 0:
return
logger.info("Adding items to Ocean for %s (%i items)" %
(self, len(json_items)))
field_id = self.get_field_unique_id()
inser... | python | def _items_to_es(self, json_items):
""" Append items JSON to ES (data source state) """
if len(json_items) == 0:
return
logger.info("Adding items to Ocean for %s (%i items)" %
(self, len(json_items)))
field_id = self.get_field_unique_id()
inser... | Append items JSON to ES (data source state) | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/elastic.py#L266-L292 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.get_identities | def get_identities(self, item):
""" Return the identities from an item.
If the repo is in GitHub, get the usernames from GitHub. """
def add_sh_github_identity(user, user_field, rol):
""" Add a new github identity to SH if it does not exists """
github_repo = None
... | python | def get_identities(self, item):
""" Return the identities from an item.
If the repo is in GitHub, get the usernames from GitHub. """
def add_sh_github_identity(user, user_field, rol):
""" Add a new github identity to SH if it does not exists """
github_repo = None
... | Return the identities from an item.
If the repo is in GitHub, get the usernames from GitHub. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L148-L211 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.get_github_login | def get_github_login(self, user, rol, commit_hash, repo):
""" rol: author or committer """
login = None
try:
login = self.github_logins[user]
except KeyError:
# Get the login from github API
GITHUB_API_URL = "https://api.github.com"
commit_... | python | def get_github_login(self, user, rol, commit_hash, repo):
""" rol: author or committer """
login = None
try:
login = self.github_logins[user]
except KeyError:
# Get the login from github API
GITHUB_API_URL = "https://api.github.com"
commit_... | rol: author or committer | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L236-L302 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.__fix_field_date | def __fix_field_date(self, item, attribute):
"""Fix possible errors in the field date"""
field_date = str_to_datetime(item[attribute])
try:
_ = int(field_date.strftime("%z")[0:3])
except ValueError:
logger.warning("%s in commit %s has a wrong format", attribute,... | python | def __fix_field_date(self, item, attribute):
"""Fix possible errors in the field date"""
field_date = str_to_datetime(item[attribute])
try:
_ = int(field_date.strftime("%z")[0:3])
except ValueError:
logger.warning("%s in commit %s has a wrong format", attribute,... | Fix possible errors in the field date | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L425-L434 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.enrich_items | def enrich_items(self, ocean_backend, events=False):
""" Implementation supporting signed-off and multiauthor/committer commits."""
headers = {"Content-Type": "application/json"}
max_items = self.elastic.max_items_bulk
current = 0
total = 0
bulk_json = ""
total... | python | def enrich_items(self, ocean_backend, events=False):
""" Implementation supporting signed-off and multiauthor/committer commits."""
headers = {"Content-Type": "application/json"}
max_items = self.elastic.max_items_bulk
current = 0
total = 0
bulk_json = ""
total... | Implementation supporting signed-off and multiauthor/committer commits. | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L480-L594 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.update_items | def update_items(self, ocean_backend, enrich_backend):
"""Retrieve the commits not present in the original repository and delete
the corresponding documents from the raw and enriched indexes"""
fltr = {
'name': 'origin',
'value': [self.perceval_backend.origin]
}
... | python | def update_items(self, ocean_backend, enrich_backend):
"""Retrieve the commits not present in the original repository and delete
the corresponding documents from the raw and enriched indexes"""
fltr = {
'name': 'origin',
'value': [self.perceval_backend.origin]
}
... | Retrieve the commits not present in the original repository and delete
the corresponding documents from the raw and enriched indexes | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L668-L725 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.delete_commit_branches | def delete_commit_branches(self, enrich_backend):
"""Delete the information about branches from the documents representing
commits in the enriched index.
:param enrich_backend: the enrich backend
"""
fltr = """
"filter": [
{
"term"... | python | def delete_commit_branches(self, enrich_backend):
"""Delete the information about branches from the documents representing
commits in the enriched index.
:param enrich_backend: the enrich backend
"""
fltr = """
"filter": [
{
"term"... | Delete the information about branches from the documents representing
commits in the enriched index.
:param enrich_backend: the enrich backend | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L727-L768 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.add_commit_branches | def add_commit_branches(self, git_repo, enrich_backend):
"""Add the information about branches to the documents representing commits in
the enriched index. Branches are obtained using the command `git ls-remote`,
then for each branch, the list of commits is retrieved via the command `git rev-lis... | python | def add_commit_branches(self, git_repo, enrich_backend):
"""Add the information about branches to the documents representing commits in
the enriched index. Branches are obtained using the command `git ls-remote`,
then for each branch, the list of commits is retrieved via the command `git rev-lis... | Add the information about branches to the documents representing commits in
the enriched index. Branches are obtained using the command `git ls-remote`,
then for each branch, the list of commits is retrieved via the command `git rev-list branch-name` and
used to update the corresponding items in... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L770-L807 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/git.py | GitEnrich.remove_commits | def remove_commits(self, items, index, attribute, origin):
"""Delete documents that correspond to commits deleted in the Git repository
:param items: target items to be deleted
:param index: target index
:param attribute: name of the term attribute to search items
:param origin:... | python | def remove_commits(self, items, index, attribute, origin):
"""Delete documents that correspond to commits deleted in the Git repository
:param items: target items to be deleted
:param index: target index
:param attribute: name of the term attribute to search items
:param origin:... | Delete documents that correspond to commits deleted in the Git repository
:param items: target items to be deleted
:param index: target index
:param attribute: name of the term attribute to search items
:param origin: name of the origin from where the items must be deleted | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/git.py#L809-L842 |
chaoss/grimoirelab-elk | utils/gelk_mapping.py | find_general_mappings | def find_general_mappings(es_major_version):
"""
Find the general mappings applied to all data sources
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched)
"""
if es_major_version not in ES_SUPPORTED:
print("Elasti... | python | def find_general_mappings(es_major_version):
"""
Find the general mappings applied to all data sources
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched)
"""
if es_major_version not in ES_SUPPORTED:
print("Elasti... | Find the general mappings applied to all data sources
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched) | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/gelk_mapping.py#L48-L92 |
chaoss/grimoirelab-elk | utils/gelk_mapping.py | find_ds_mapping | def find_ds_mapping(data_source, es_major_version):
"""
Find the mapping given a perceval data source
:param data_source: name of the perceval data source
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched)
"""
mappin... | python | def find_ds_mapping(data_source, es_major_version):
"""
Find the mapping given a perceval data source
:param data_source: name of the perceval data source
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched)
"""
mappin... | Find the mapping given a perceval data source
:param data_source: name of the perceval data source
:param es_major_version: string with the major version for Elasticsearch
:return: a dict with the mappings (raw and enriched) | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/gelk_mapping.py#L95-L128 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_aoc.py | areas_of_code | def areas_of_code(git_enrich, in_conn, out_conn, block_size=100):
"""Build and index for areas of code from a given Perceval RAW index.
:param block_size: size of items block.
:param git_enrich: GitEnrich object to deal with SortingHat affiliations.
:param in_conn: ESPandasConnector to read from.
:... | python | def areas_of_code(git_enrich, in_conn, out_conn, block_size=100):
"""Build and index for areas of code from a given Perceval RAW index.
:param block_size: size of items block.
:param git_enrich: GitEnrich object to deal with SortingHat affiliations.
:param in_conn: ESPandasConnector to read from.
:... | Build and index for areas of code from a given Perceval RAW index.
:param block_size: size of items block.
:param git_enrich: GitEnrich object to deal with SortingHat affiliations.
:param in_conn: ESPandasConnector to read from.
:param out_conn: ESPandasConnector to write to.
:return: number of doc... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_aoc.py#L214-L226 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_aoc.py | ESPandasConnector.make_hashcode | def make_hashcode(uuid, filepath, file_event):
"""Generate a SHA1 based on the given arguments.
:param uuid: perceval uuid of the item
:param filepath: path of the corresponding file
:param file_event: commit file event
:returns: a SHA1 hash code
"""
content = ':... | python | def make_hashcode(uuid, filepath, file_event):
"""Generate a SHA1 based on the given arguments.
:param uuid: perceval uuid of the item
:param filepath: path of the corresponding file
:param file_event: commit file event
:returns: a SHA1 hash code
"""
content = ':... | Generate a SHA1 based on the given arguments.
:param uuid: perceval uuid of the item
:param filepath: path of the corresponding file
:param file_event: commit file event
:returns: a SHA1 hash code | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_aoc.py#L54-L64 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_aoc.py | ESPandasConnector.write | def write(self, items):
"""Write items into ElasticSearch.
:param items: Pandas DataFrame
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
# Uploading info to the new ES
rows = items.to_dict("index")
docs = []
... | python | def write(self, items):
"""Write items into ElasticSearch.
:param items: Pandas DataFrame
"""
if self._read_only:
raise IOError("Cannot write, Connector created as Read Only")
# Uploading info to the new ES
rows = items.to_dict("index")
docs = []
... | Write items into ElasticSearch.
:param items: Pandas DataFrame | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_aoc.py#L113-L141 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/study_ceres_aoc.py | AreasOfCode.process | def process(self, items_block):
"""Process items to add file related information.
Eventize items creating one new item per each file found in the commit (excluding
files with no actions performed on them). For each event, file path, file name,
path parts, file type and file extension ar... | python | def process(self, items_block):
"""Process items to add file related information.
Eventize items creating one new item per each file found in the commit (excluding
files with no actions performed on them). For each event, file path, file name,
path parts, file type and file extension ar... | Process items to add file related information.
Eventize items creating one new item per each file found in the commit (excluding
files with no actions performed on them). For each event, file path, file name,
path parts, file type and file extension are added as fields.
:param items_bl... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_aoc.py#L165-L211 |
chaoss/grimoirelab-elk | grimoire_elk/raw/mattermost.py | MattermostOcean.get_perceval_params_from_url | def get_perceval_params_from_url(cls, url):
""" Get the perceval params given a URL for the data source """
params = []
dparam = cls.get_arthur_params_from_url(url)
params.append(dparam['url'])
params.append(dparam['channel'])
return params | python | def get_perceval_params_from_url(cls, url):
""" Get the perceval params given a URL for the data source """
params = []
dparam = cls.get_arthur_params_from_url(url)
params.append(dparam['url'])
params.append(dparam['channel'])
return params | Get the perceval params given a URL for the data source | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/mattermost.py#L77-L84 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/utils.py | get_repository_filter | def get_repository_filter(perceval_backend, perceval_backend_name,
term=False):
""" Get the filter needed for get the items in a repository """
from .github import GITHUB
filter_ = {}
if not perceval_backend:
return filter_
field = 'origin'
value = perceval_b... | python | def get_repository_filter(perceval_backend, perceval_backend_name,
term=False):
""" Get the filter needed for get the items in a repository """
from .github import GITHUB
filter_ = {}
if not perceval_backend:
return filter_
field = 'origin'
value = perceval_b... | Get the filter needed for get the items in a repository | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/utils.py#L47-L88 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/utils.py | get_time_diff_days | def get_time_diff_days(start, end):
''' Number of days between two dates in UTC format '''
if start is None or end is None:
return None
if type(start) is not datetime.datetime:
start = parser.parse(start).replace(tzinfo=None)
if type(end) is not datetime.datetime:
end = parser... | python | def get_time_diff_days(start, end):
''' Number of days between two dates in UTC format '''
if start is None or end is None:
return None
if type(start) is not datetime.datetime:
start = parser.parse(start).replace(tzinfo=None)
if type(end) is not datetime.datetime:
end = parser... | Number of days between two dates in UTC format | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/utils.py#L91-L106 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/utils.py | unixtime_to_datetime | def unixtime_to_datetime(ut):
"""Convert a unixtime timestamp to a datetime object.
The function converts a timestamp in Unix format to a
datetime object. UTC timezone will also be set.
:param ut: Unix timestamp to convert
:returns: a datetime object
:raises InvalidDateError: when the given time... | python | def unixtime_to_datetime(ut):
"""Convert a unixtime timestamp to a datetime object.
The function converts a timestamp in Unix format to a
datetime object. UTC timezone will also be set.
:param ut: Unix timestamp to convert
:returns: a datetime object
:raises InvalidDateError: when the given time... | Convert a unixtime timestamp to a datetime object.
The function converts a timestamp in Unix format to a
datetime object. UTC timezone will also be set.
:param ut: Unix timestamp to convert
:returns: a datetime object
:raises InvalidDateError: when the given timestamp cannot be
converted int... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/utils.py#L110-L122 |
chaoss/grimoirelab-elk | grimoire_elk/raw/dockerhub.py | DockerHubOcean.get_arthur_params_from_url | def get_arthur_params_from_url(cls, url):
# In the url the org and the repository are included
params = url.split()
""" Get the arthur params given a URL for the data source """
params = {"owner": params[0], "repository": params[1]}
return params | python | def get_arthur_params_from_url(cls, url):
# In the url the org and the repository are included
params = url.split()
""" Get the arthur params given a URL for the data source """
params = {"owner": params[0], "repository": params[1]}
return params | Get the arthur params given a URL for the data source | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/raw/dockerhub.py#L73-L80 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/phabricator.py | PhabricatorEnrich.get_identities | def get_identities(self, item):
""" Return the identities from an item """
if 'authorData' in item['data']['fields']:
user = self.get_sh_identity(item['data']['fields']['authorData'])
yield user
if 'ownerData' in item['data']['fields']:
user = self.get_sh_id... | python | def get_identities(self, item):
""" Return the identities from an item """
if 'authorData' in item['data']['fields']:
user = self.get_sh_identity(item['data']['fields']['authorData'])
yield user
if 'ownerData' in item['data']['fields']:
user = self.get_sh_id... | Return the identities from an item | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/phabricator.py#L86-L95 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/phabricator.py | PhabricatorEnrich.get_rich_events | def get_rich_events(self, item):
"""
In the events there are some common fields with the task. The name
of the field must be the same in the task and in the event
so we can filer using it in task and event at the same time.
* Fields that don't change: the field does not change w... | python | def get_rich_events(self, item):
"""
In the events there are some common fields with the task. The name
of the field must be the same in the task and in the event
so we can filer using it in task and event at the same time.
* Fields that don't change: the field does not change w... | In the events there are some common fields with the task. The name
of the field must be the same in the task and in the event
so we can filer using it in task and event at the same time.
* Fields that don't change: the field does not change with the events
in a task so the value is alwa... | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/phabricator.py#L130-L227 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/phabricator.py | PhabricatorEnrich.__fill_phab_ids | def __fill_phab_ids(self, item):
""" Get mappings between phab ids and names """
for p in item['projects']:
if p and 'name' in p and 'phid' in p:
self.phab_ids_names[p['phid']] = p['name']
if 'authorData' not in item['fields'] or not item['fields']['authorData']:
... | python | def __fill_phab_ids(self, item):
""" Get mappings between phab ids and names """
for p in item['projects']:
if p and 'name' in p and 'phid' in p:
self.phab_ids_names[p['phid']] = p['name']
if 'authorData' not in item['fields'] or not item['fields']['authorData']:
... | Get mappings between phab ids and names | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/phabricator.py#L229-L247 |
robdmc/crontabs | crontabs/crontabs.py | Tab.starting_at | def starting_at(self, datetime_or_str):
"""
Set the starting time for the cron job. If not specified, the starting time will always
be the beginning of the interval that is current when the cron is started.
:param datetime_or_str: a datetime object or a string that dateutil.parser can ... | python | def starting_at(self, datetime_or_str):
"""
Set the starting time for the cron job. If not specified, the starting time will always
be the beginning of the interval that is current when the cron is started.
:param datetime_or_str: a datetime object or a string that dateutil.parser can ... | Set the starting time for the cron job. If not specified, the starting time will always
be the beginning of the interval that is current when the cron is started.
:param datetime_or_str: a datetime object or a string that dateutil.parser can understand
:return: self | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/crontabs.py#L61-L75 |
robdmc/crontabs | crontabs/crontabs.py | Tab.every | def every(self, **kwargs):
"""
Specify the interval at which you want the job run. Takes exactly one keyword argument.
That argument must be one named one of [second, minute, hour, day, week, month, year] or
their plural equivalents.
:param kwargs: Exactly one keyword argument
... | python | def every(self, **kwargs):
"""
Specify the interval at which you want the job run. Takes exactly one keyword argument.
That argument must be one named one of [second, minute, hour, day, week, month, year] or
their plural equivalents.
:param kwargs: Exactly one keyword argument
... | Specify the interval at which you want the job run. Takes exactly one keyword argument.
That argument must be one named one of [second, minute, hour, day, week, month, year] or
their plural equivalents.
:param kwargs: Exactly one keyword argument
:return: self | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/crontabs.py#L77-L91 |
robdmc/crontabs | crontabs/crontabs.py | Tab.run | def run(self, func, *func_args, **func__kwargs):
"""
Specify the function to run at the scheduled times
:param func: a callable
:param func_args: the args to the callable
:param func__kwargs: the kwargs to the callable
:return:
"""
self._func = func
... | python | def run(self, func, *func_args, **func__kwargs):
"""
Specify the function to run at the scheduled times
:param func: a callable
:param func_args: the args to the callable
:param func__kwargs: the kwargs to the callable
:return:
"""
self._func = func
... | Specify the function to run at the scheduled times
:param func: a callable
:param func_args: the args to the callable
:param func__kwargs: the kwargs to the callable
:return: | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/crontabs.py#L93-L105 |
robdmc/crontabs | crontabs/crontabs.py | Tab._get_target | def _get_target(self):
"""
returns a callable with no arguments designed
to be the target of a Subprocess
"""
if None in [self._func, self._func_kwargs, self._func_kwargs, self._every_kwargs]:
raise ValueError('You must call the .every() and .run() methods on every ta... | python | def _get_target(self):
"""
returns a callable with no arguments designed
to be the target of a Subprocess
"""
if None in [self._func, self._func_kwargs, self._func_kwargs, self._every_kwargs]:
raise ValueError('You must call the .every() and .run() methods on every ta... | returns a callable with no arguments designed
to be the target of a Subprocess | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/crontabs.py#L197-L204 |
robdmc/crontabs | crontabs/processes.py | wrapped_target | def wrapped_target(target, q_stdout, q_stderr, q_error, robust, name, *args, **kwargs): # pragma: no cover
"""
Wraps a target with queues replacing stdout and stderr
"""
import sys
sys.stdout = IOQueue(q_stdout)
sys.stderr = IOQueue(q_stderr)
try:
target(*args, **kwargs)
except... | python | def wrapped_target(target, q_stdout, q_stderr, q_error, robust, name, *args, **kwargs): # pragma: no cover
"""
Wraps a target with queues replacing stdout and stderr
"""
import sys
sys.stdout = IOQueue(q_stdout)
sys.stderr = IOQueue(q_stderr)
try:
target(*args, **kwargs)
except... | Wraps a target with queues replacing stdout and stderr | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/processes.py#L85-L107 |
robdmc/crontabs | crontabs/processes.py | ProcessMonitor.loop | def loop(self, max_seconds=None):
"""
Main loop for the process. This will run continuously until maxiter
"""
loop_started = datetime.datetime.now()
self._is_running = True
while self._is_running:
self.process_error_queue(self.q_error)
if max_se... | python | def loop(self, max_seconds=None):
"""
Main loop for the process. This will run continuously until maxiter
"""
loop_started = datetime.datetime.now()
self._is_running = True
while self._is_running:
self.process_error_queue(self.q_error)
if max_se... | Main loop for the process. This will run continuously until maxiter | https://github.com/robdmc/crontabs/blob/3a347f9309eb1b4c7c222363ede338a158f5072c/crontabs/processes.py#L156-L174 |
gusutabopb/aioinflux | aioinflux/serialization/common.py | escape | def escape(string, escape_pattern):
"""Assistant function for string escaping"""
try:
return string.translate(escape_pattern)
except AttributeError:
warnings.warn("Non-string-like data passed. "
"Attempting to convert to 'str'.")
return str(string).translate(tag... | python | def escape(string, escape_pattern):
"""Assistant function for string escaping"""
try:
return string.translate(escape_pattern)
except AttributeError:
warnings.warn("Non-string-like data passed. "
"Attempting to convert to 'str'.")
return str(string).translate(tag... | Assistant function for string escaping | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/common.py#L13-L20 |
gusutabopb/aioinflux | aioinflux/serialization/usertype.py | _make_serializer | def _make_serializer(meas, schema, rm_none, extra_tags, placeholder): # noqa: C901
"""Factory of line protocol parsers"""
_validate_schema(schema, placeholder)
tags = []
fields = []
ts = None
meas = meas
for k, t in schema.items():
if t is MEASUREMENT:
meas = f"{{i.{k}}}... | python | def _make_serializer(meas, schema, rm_none, extra_tags, placeholder): # noqa: C901
"""Factory of line protocol parsers"""
_validate_schema(schema, placeholder)
tags = []
fields = []
ts = None
meas = meas
for k, t in schema.items():
if t is MEASUREMENT:
meas = f"{{i.{k}}}... | Factory of line protocol parsers | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/usertype.py#L67-L122 |
gusutabopb/aioinflux | aioinflux/serialization/usertype.py | lineprotocol | def lineprotocol(
cls=None,
*,
schema: Optional[Mapping[str, type]] = None,
rm_none: bool = False,
extra_tags: Optional[Mapping[str, str]] = None,
placeholder: bool = False
):
"""Adds ``to_lineprotocol`` method to arbitrary user-defined classes
:param cls: Class ... | python | def lineprotocol(
cls=None,
*,
schema: Optional[Mapping[str, type]] = None,
rm_none: bool = False,
extra_tags: Optional[Mapping[str, str]] = None,
placeholder: bool = False
):
"""Adds ``to_lineprotocol`` method to arbitrary user-defined classes
:param cls: Class ... | Adds ``to_lineprotocol`` method to arbitrary user-defined classes
:param cls: Class to monkey-patch
:param schema: Schema dictionary (attr/type pairs).
:param rm_none: Whether apply a regex to remove ``None`` values.
If ``False``, passing ``None`` values to boolean, integer or float or time fields
... | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/usertype.py#L125-L152 |
gusutabopb/aioinflux | aioinflux/serialization/mapping.py | serialize | def serialize(point: Mapping, measurement=None, **extra_tags) -> bytes:
"""Converts dictionary-like data into a single line protocol line (point)"""
tags = _serialize_tags(point, extra_tags)
return (
f'{_serialize_measurement(point, measurement)}'
f'{"," if tags else ""}{tags} '
f'{_... | python | def serialize(point: Mapping, measurement=None, **extra_tags) -> bytes:
"""Converts dictionary-like data into a single line protocol line (point)"""
tags = _serialize_tags(point, extra_tags)
return (
f'{_serialize_measurement(point, measurement)}'
f'{"," if tags else ""}{tags} '
f'{_... | Converts dictionary-like data into a single line protocol line (point) | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/mapping.py#L9-L17 |
gusutabopb/aioinflux | aioinflux/serialization/mapping.py | _serialize_fields | def _serialize_fields(point):
"""Field values can be floats, integers, strings, or Booleans."""
output = []
for k, v in point['fields'].items():
k = escape(k, key_escape)
if isinstance(v, bool):
output.append(f'{k}={v}')
elif isinstance(v, int):
output.append(... | python | def _serialize_fields(point):
"""Field values can be floats, integers, strings, or Booleans."""
output = []
for k, v in point['fields'].items():
k = escape(k, key_escape)
if isinstance(v, bool):
output.append(f'{k}={v}')
elif isinstance(v, int):
output.append(... | Field values can be floats, integers, strings, or Booleans. | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/mapping.py#L57-L74 |
gusutabopb/aioinflux | aioinflux/serialization/__init__.py | serialize | def serialize(data, measurement=None, tag_columns=None, **extra_tags):
"""Converts input data into line protocol format"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('utf-8')
elif hasattr(data, 'to_lineprotocol'):
return data.to_linepro... | python | def serialize(data, measurement=None, tag_columns=None, **extra_tags):
"""Converts input data into line protocol format"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('utf-8')
elif hasattr(data, 'to_lineprotocol'):
return data.to_linepro... | Converts input data into line protocol format | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/__init__.py#L9-L24 |
gusutabopb/aioinflux | aioinflux/iterutils.py | iterpoints | def iterpoints(resp: dict, parser: Optional[Callable] = None) -> Iterator[Any]:
"""Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata... | python | def iterpoints(resp: dict, parser: Optional[Callable] = None) -> Iterator[Any]:
"""Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata... | Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata.
In case a specific format is needed, an optional ``parser`` argument can be pass... | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/iterutils.py#L6-L48 |
gusutabopb/aioinflux | aioinflux/serialization/dataframe.py | parse | def parse(resp) -> DataFrameType:
"""Makes a dictionary of DataFrames from a response object"""
statements = []
for statement in resp['results']:
series = {}
for s in statement.get('series', []):
series[_get_name(s)] = _drop_zero_index(_serializer(s))
statements.append(se... | python | def parse(resp) -> DataFrameType:
"""Makes a dictionary of DataFrames from a response object"""
statements = []
for statement in resp['results']:
series = {}
for s in statement.get('series', []):
series[_get_name(s)] = _drop_zero_index(_serializer(s))
statements.append(se... | Makes a dictionary of DataFrames from a response object | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/dataframe.py#L44-L59 |
gusutabopb/aioinflux | aioinflux/serialization/dataframe.py | _itertuples | def _itertuples(df):
"""Custom implementation of ``DataFrame.itertuples`` that
returns plain tuples instead of namedtuples. About 50% faster.
"""
cols = [df.iloc[:, k] for k in range(len(df.columns))]
return zip(df.index, *cols) | python | def _itertuples(df):
"""Custom implementation of ``DataFrame.itertuples`` that
returns plain tuples instead of namedtuples. About 50% faster.
"""
cols = [df.iloc[:, k] for k in range(len(df.columns))]
return zip(df.index, *cols) | Custom implementation of ``DataFrame.itertuples`` that
returns plain tuples instead of namedtuples. About 50% faster. | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/dataframe.py#L65-L70 |
gusutabopb/aioinflux | aioinflux/serialization/dataframe.py | serialize | def serialize(df, measurement, tag_columns=None, **extra_tags) -> bytes:
"""Converts a Pandas DataFrame into line protocol format"""
# Pre-processing
if measurement is None:
raise ValueError("Missing 'measurement'")
if not isinstance(df.index, pd.DatetimeIndex):
raise ValueError('DataFra... | python | def serialize(df, measurement, tag_columns=None, **extra_tags) -> bytes:
"""Converts a Pandas DataFrame into line protocol format"""
# Pre-processing
if measurement is None:
raise ValueError("Missing 'measurement'")
if not isinstance(df.index, pd.DatetimeIndex):
raise ValueError('DataFra... | Converts a Pandas DataFrame into line protocol format | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/dataframe.py#L86-L127 |
gusutabopb/aioinflux | aioinflux/client.py | runner | def runner(coro):
"""Function execution decorator."""
@wraps(coro)
def inner(self, *args, **kwargs):
if self.mode == 'async':
return coro(self, *args, **kwargs)
return self._loop.run_until_complete(coro(self, *args, **kwargs))
return inner | python | def runner(coro):
"""Function execution decorator."""
@wraps(coro)
def inner(self, *args, **kwargs):
if self.mode == 'async':
return coro(self, *args, **kwargs)
return self._loop.run_until_complete(coro(self, *args, **kwargs))
return inner | Function execution decorator. | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L25-L34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.