_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q257100 | sklearn2pmml | validation | def sklearn2pmml(pipeline, pmml, user_classpath = [], with_repr = False, debug = False, java_encoding = "UTF-8"):
"""Converts a fitted Scikit-Learn pipeline to PMML.
Parameters:
----------
pipeline: PMMLPipeline
The pipeline.
pmml: string
The path to where the PMML document should be stored.
user_classpath... | python | {
"resource": ""
} |
q257101 | make_tpot_pmml_config | validation | def make_tpot_pmml_config(config, user_classpath = []):
"""Translates a regular TPOT configuration to a PMML-compatible TPOT configuration.
Parameters:
----------
obj: config
The configuration dictionary.
user_classpath: list of strings, optional
The paths to JAR files that provide custom Transformer, Select... | python | {
"resource": ""
} |
q257102 | BaseFormSetFactory.construct_formset | validation | def construct_formset(self):
"""
Returns an instance of the formset
"""
formset_class = self.get_formset()
if hasattr(self, 'get_extra_form_kwargs'):
klass = type(self).__name__
raise DeprecationWarning(
'Calling {0}.get_extra_form_kwargs i... | python | {
"resource": ""
} |
q257103 | FormSetMixin.get_success_url | validation | def get_success_url(self):
"""
Returns the supplied URL.
"""
if self.success_url:
url = self.success_url
else:
# Default to returning to the same page
url = self.request.get_full_path()
return url | python | {
"resource": ""
} |
q257104 | ModelFormSetMixin.formset_valid | validation | def formset_valid(self, formset):
"""
If the formset is valid, save the associated models.
"""
self.object_list = formset.save()
return super(ModelFormSetMixin, self).formset_valid(formset) | python | {
"resource": ""
} |
q257105 | ProcessFormSetView.get | validation | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates a blank version of the formset.
"""
formset = self.construct_formset()
return self.render_to_response(self.get_context_data(formset=formset)) | python | {
"resource": ""
} |
q257106 | ProcessFormSetView.post | validation | def post(self, request, *args, **kwargs):
"""
Handles POST requests, instantiating a formset instance with the passed
POST variables and then checked for validity.
"""
formset = self.construct_formset()
if formset.is_valid():
return self.formset_valid(formset)... | python | {
"resource": ""
} |
q257107 | InlineFormSetFactory.construct_formset | validation | def construct_formset(self):
"""
Overrides construct_formset to attach the model class as
an attribute of the returned formset instance.
"""
formset = super(InlineFormSetFactory, self).construct_formset()
formset.model = self.inline_model
return formset | python | {
"resource": ""
} |
q257108 | ModelFormWithInlinesMixin.forms_valid | validation | def forms_valid(self, form, inlines):
"""
If the form and formsets are valid, save the associated models.
"""
response = self.form_valid(form)
for formset in inlines:
formset.save()
return response | python | {
"resource": ""
} |
q257109 | ModelFormWithInlinesMixin.forms_invalid | validation | def forms_invalid(self, form, inlines):
"""
If the form or formsets are invalid, re-render the context data with the
data-filled form and formsets and errors.
"""
return self.render_to_response(self.get_context_data(form=form, inlines=inlines)) | python | {
"resource": ""
} |
q257110 | ModelFormWithInlinesMixin.construct_inlines | validation | def construct_inlines(self):
"""
Returns the inline formset instances
"""
inline_formsets = []
for inline_class in self.get_inlines():
inline_instance = inline_class(self.model, self.request, self.object, self.kwargs, self)
inline_formset = inline_instance... | python | {
"resource": ""
} |
q257111 | ProcessFormWithInlinesView.get | validation | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates a blank version of the form and formsets.
"""
form_class = self.get_form_class()
form = self.get_form(form_class)
inlines = self.construct_inlines()
return self.render_to_response(s... | python | {
"resource": ""
} |
q257112 | ProcessFormWithInlinesView.post | validation | def post(self, request, *args, **kwargs):
"""
Handles POST requests, instantiating a form and formset instances with the passed
POST variables and then checked for validity.
"""
form_class = self.get_form_class()
form = self.get_form(form_class)
if form.is_valid(... | python | {
"resource": ""
} |
q257113 | NamedFormsetsMixin.get_context_data | validation | def get_context_data(self, **kwargs):
"""
If `inlines_names` has been defined, add each formset to the context under
its corresponding entry in `inlines_names`
"""
context = {}
inlines_names = self.get_inlines_names()
if inlines_names:
# We have forms... | python | {
"resource": ""
} |
q257114 | SortHelper.get_params_for_field | validation | def get_params_for_field(self, field_name, sort_type=None):
"""
If sort_type is None - inverse current sort for field, if no sorted - use asc
"""
if not sort_type:
if self.initial_sort == field_name:
sort_type = 'desc' if self.initial_sort_type == 'asc' else '... | python | {
"resource": ""
} |
q257115 | BaseCalendarMonthView.get_start_date | validation | def get_start_date(self, obj):
"""
Returns the start date for a model instance
"""
obj_date = getattr(obj, self.get_date_field())
try:
obj_date = obj_date.date()
except AttributeError:
# It's a date rather than datetime, so we use it as is
... | python | {
"resource": ""
} |
q257116 | BaseCalendarMonthView.get_end_date | validation | def get_end_date(self, obj):
"""
Returns the end date for a model instance
"""
obj_date = getattr(obj, self.get_end_date_field())
try:
obj_date = obj_date.date()
except AttributeError:
# It's a date rather than datetime, so we use it as is
... | python | {
"resource": ""
} |
q257117 | BaseCalendarMonthView.get_first_of_week | validation | def get_first_of_week(self):
"""
Returns an integer representing the first day of the week.
0 represents Monday, 6 represents Sunday.
"""
if self.first_of_week is None:
raise ImproperlyConfigured("%s.first_of_week is required." % self.__class__.__name__)
if s... | python | {
"resource": ""
} |
q257118 | BaseCalendarMonthView.get_queryset | validation | def get_queryset(self):
"""
Returns a queryset of models for the month requested
"""
qs = super(BaseCalendarMonthView, self).get_queryset()
year = self.get_year()
month = self.get_month()
date_field = self.get_date_field()
end_date_field = self.get_end_d... | python | {
"resource": ""
} |
q257119 | BaseCalendarMonthView.get_context_data | validation | def get_context_data(self, **kwargs):
"""
Injects variables necessary for rendering the calendar into the context.
Variables added are: `calendar`, `weekdays`, `month`, `next_month` and `previous_month`.
"""
data = super(BaseCalendarMonthView, self).get_context_data(**kwargs)
... | python | {
"resource": ""
} |
q257120 | ColorfulModule.with_setup | validation | def with_setup(self, colormode=None, colorpalette=None, extend_colors=False):
"""
Return a new Colorful object with the given color config.
"""
colorful = Colorful(
colormode=self.colorful.colormode,
colorpalette=copy.copy(self.colorful.colorpalette)
)
... | python | {
"resource": ""
} |
q257121 | parse_colors | validation | def parse_colors(path):
"""Parse the given color files.
Supported are:
* .txt for X11 colors
* .json for colornames
"""
if path.endswith(".txt"):
return parse_rgb_txt_file(path)
elif path.endswith(".json"):
return parse_json_color_file(path)
raise TypeError("col... | python | {
"resource": ""
} |
q257122 | parse_rgb_txt_file | validation | def parse_rgb_txt_file(path):
"""
Parse the given rgb.txt file into a Python dict.
See https://en.wikipedia.org/wiki/X11_color_names for more information
:param str path: the path to the X11 rgb.txt file
"""
#: Holds the generated color dict
color_dict = {}
with open(path, 'r') as rgb... | python | {
"resource": ""
} |
q257123 | parse_json_color_file | validation | def parse_json_color_file(path):
"""Parse a JSON color file.
The JSON has to be in the following format:
.. code:: json
[{"name": "COLOR_NAME", "hex": "#HEX"}, ...]
:param str path: the path to the JSON color file
"""
with open(path, "r") as color_file:
color_list = json.load(... | python | {
"resource": ""
} |
q257124 | sanitize_color_palette | validation | def sanitize_color_palette(colorpalette):
"""
Sanitze the given color palette so it can
be safely used by Colorful.
It will convert colors specified in hex RGB to
a RGB channel triplet.
"""
new_palette = {}
def __make_valid_color_name(name):
"""
Convert the given name i... | python | {
"resource": ""
} |
q257125 | detect_color_support | validation | def detect_color_support(env): # noqa
"""
Detect what color palettes are supported.
It'll return a valid color mode to use
with colorful.
:param dict env: the environment dict like returned by ``os.envion``
"""
if env.get('COLORFUL_DISABLE', '0') == '1':
return NO_COLORS
if en... | python | {
"resource": ""
} |
q257126 | rgb_to_ansi256 | validation | def rgb_to_ansi256(r, g, b):
"""
Convert RGB to ANSI 256 color
"""
if r == g and g == b:
if r < 8:
return 16
if r > 248:
return 231
return round(((r - 8) / 247.0) * 24) + 232
ansi_r = 36 * round(r / 255.0 * 5.0)
ansi_g = 6 * round(g / 255.0 * 5.0... | python | {
"resource": ""
} |
q257127 | rgb_to_ansi16 | validation | def rgb_to_ansi16(r, g, b, use_bright=False):
"""
Convert RGB to ANSI 16 color
"""
ansi_b = round(b / 255.0) << 2
ansi_g = round(g / 255.0) << 1
ansi_r = round(r / 255.0)
ansi = (90 if use_bright else 30) + (ansi_b | ansi_g | ansi_r)
return ansi | python | {
"resource": ""
} |
q257128 | hex_to_rgb | validation | def hex_to_rgb(value):
"""
Convert the given hex string to a
valid RGB channel triplet.
"""
value = value.lstrip('#')
check_hex(value)
length = len(value)
step = int(length / 3)
return tuple(int(value[i:i+step], 16) for i in range(0, length, step)) | python | {
"resource": ""
} |
q257129 | check_hex | validation | def check_hex(value):
"""
Check if the given hex value is a valid RGB color
It should match the format: [0-9a-fA-F]
and be of length 3 or 6.
"""
length = len(value)
if length not in (3, 6):
raise ValueError('Hex string #{} is too long'.format(value))
regex = r'[0-9a-f]{{{length... | python | {
"resource": ""
} |
q257130 | translate_rgb_to_ansi_code | validation | def translate_rgb_to_ansi_code(red, green, blue, offset, colormode):
"""
Translate the given RGB color into the appropriate ANSI escape code
for the given color mode.
The offset is used for the base color which is used.
The ``colormode`` has to be one of:
* 0: no colors / disabled
*... | python | {
"resource": ""
} |
q257131 | translate_colorname_to_ansi_code | validation | def translate_colorname_to_ansi_code(colorname, offset, colormode, colorpalette):
"""
Translate the given color name to a valid
ANSI escape code.
:parma str colorname: the name of the color to resolve
:parma str offset: the offset for the color code
:param int colormode: the color mode to use. ... | python | {
"resource": ""
} |
q257132 | resolve_modifier_to_ansi_code | validation | def resolve_modifier_to_ansi_code(modifiername, colormode):
"""
Resolve the given modifier name to a valid
ANSI escape code.
:param str modifiername: the name of the modifier to resolve
:param int colormode: the color mode to use. See ``translate_rgb_to_ansi_code``
:returns str: the ANSI escap... | python | {
"resource": ""
} |
q257133 | translate_style | validation | def translate_style(style, colormode, colorpalette):
"""
Translate the given style to an ANSI escape code
sequence.
``style`` examples are:
* green
* bold
* red_on_black
* bold_green
* italic_yellow_on_cyan
:param str style: the style to translate
:param int colormode: the... | python | {
"resource": ""
} |
q257134 | style_string | validation | def style_string(string, ansi_style, colormode, nested=False):
"""
Style the given string according to the given
ANSI style string.
:param str string: the string to style
:param tuple ansi_style: the styling string returned by ``translate_style``
:param int colormode: the color mode to use. See... | python | {
"resource": ""
} |
q257135 | Colorful.colorpalette | validation | def colorpalette(self, colorpalette):
"""
Set the colorpalette which should be used
"""
if isinstance(colorpalette, str): # we assume it's a path to a color file
colorpalette = colors.parse_colors(colorpalette)
self._colorpalette = colors.sanitize_color_palette(colo... | python | {
"resource": ""
} |
q257136 | Colorful.setup | validation | def setup(self, colormode=None, colorpalette=None, extend_colors=False):
"""
Setup this colorful object by setting a ``colormode`` and
the ``colorpalette`. The ``extend_colors`` flag is used
to extend the currently active color palette instead of
replacing it.
:param int... | python | {
"resource": ""
} |
q257137 | Colorful.use_style | validation | def use_style(self, style_name):
"""
Use a predefined style as color palette
:param str style_name: the name of the style
"""
try:
style = getattr(styles, style_name.upper())
except AttributeError:
raise ColorfulError('the style "{0}" is undefined... | python | {
"resource": ""
} |
q257138 | Colorful.format | validation | def format(self, string, *args, **kwargs):
"""
Format the given string with the given ``args`` and ``kwargs``.
The string can contain references to ``c`` which is provided by
this colorful object.
:param str string: the string to format
"""
return string.format(c... | python | {
"resource": ""
} |
q257139 | readattr | validation | def readattr(path, name):
"""
Read attribute from sysfs and return as string
"""
try:
f = open(USB_SYS_PREFIX + path + "/" + name)
return f.readline().rstrip("\n")
except IOError:
return None | python | {
"resource": ""
} |
q257140 | find_ports | validation | def find_ports(device):
"""
Find the port chain a device is plugged on.
This is done by searching sysfs for a device that matches the device
bus/address combination.
Useful when the underlying usb lib does not return device.port_number for
whatever reason.
"""
bus_id = device.bus
d... | python | {
"resource": ""
} |
q257141 | TemperDevice.get_data | validation | def get_data(self, reset_device=False):
"""
Get data from the USB device.
"""
try:
if reset_device:
self._device.reset()
# detach kernel driver from both interfaces if attached, so we can set_configuration()
for interface in [0,1]:
... | python | {
"resource": ""
} |
q257142 | TemperDevice.get_humidity | validation | def get_humidity(self, sensors=None):
"""
Get device humidity reading.
Params:
- sensors: optional list of sensors to get a reading for, examples:
[0,] - get reading for sensor 0
[0, 1,] - get reading for sensors 0 and 1
None - get readings for all sensors
... | python | {
"resource": ""
} |
q257143 | TemperDevice._interrupt_read | validation | def _interrupt_read(self):
"""
Read data from device.
"""
data = self._device.read(ENDPOINT, REQ_INT_LEN, timeout=TIMEOUT)
LOGGER.debug('Read data: %r', data)
return data | python | {
"resource": ""
} |
q257144 | Github.read_file_from_uri | validation | def read_file_from_uri(self, uri):
"""Reads the file from Github
:param uri: URI of the Github raw File
:returns: UTF-8 text with the content
"""
logger.debug("Reading %s" % (uri))
self.__check_looks_like_uri(uri)
try:
req = urllib.request.Request(... | python | {
"resource": ""
} |
q257145 | TaskRawDataArthurCollection.measure_memory | validation | def measure_memory(cls, obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
# Important mark as seen *before* entering recursion to gracefully... | python | {
"resource": ""
} |
q257146 | TaskRawDataArthurCollection.__create_arthur_json | validation | def __create_arthur_json(self, repo, backend_args):
""" Create the JSON for configuring arthur to collect data
https://github.com/grimoirelab/arthur#adding-tasks
Sample for git:
{
"tasks": [
{
"task_id": "arthur.git",
"backend": "git"... | python | {
"resource": ""
} |
q257147 | TaskIdentitiesExport.sha_github_file | validation | def sha_github_file(cls, config, repo_file, repository_api, repository_branch):
""" Return the GitHub SHA for a file in the repository """
repo_file_sha = None
cfg = config.get_conf()
github_token = cfg['sortinghat']['identities_api_token']
headers = {"Authorization": "token " ... | python | {
"resource": ""
} |
q257148 | TaskIdentitiesMerge.__get_uuids_from_profile_name | validation | def __get_uuids_from_profile_name(self, profile_name):
""" Get the uuid for a profile name """
uuids = []
with self.db.connect() as session:
query = session.query(Profile).\
filter(Profile.name == profile_name)
profiles = query.all()
if profil... | python | {
"resource": ""
} |
q257149 | get_raw | validation | def get_raw(config, backend_section, arthur):
"""Execute the raw phase for a given backend section, optionally using Arthur
:param config: a Mordred config object
:param backend_section: the backend section where the raw phase is executed
:param arthur: if true, it enables Arthur to collect the raw dat... | python | {
"resource": ""
} |
q257150 | get_identities | validation | def get_identities(config):
"""Execute the merge identities phase
:param config: a Mordred config object
"""
TaskProjects(config).execute()
task = TaskIdentitiesMerge(config)
task.execute()
logging.info("Merging identities finished!") | python | {
"resource": ""
} |
q257151 | get_enrich | validation | def get_enrich(config, backend_section):
"""Execute the enrich phase for a given backend section
:param config: a Mordred config object
:param backend_section: the backend section where the enrich phase is executed
"""
TaskProjects(config).execute()
task = TaskEnrich(config, backend_section=ba... | python | {
"resource": ""
} |
q257152 | get_panels | validation | def get_panels(config):
"""Execute the panels phase
:param config: a Mordred config object
"""
task = TaskPanels(config)
task.execute()
task = TaskPanelsMenu(config)
task.execute()
logging.info("Panels creation finished!") | python | {
"resource": ""
} |
q257153 | config_logging | validation | def config_logging(debug):
"""Config logging level output output"""
if debug:
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
logging.debug("Debug mode activated")
else:
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') | python | {
"resource": ""
} |
q257154 | get_params_parser | validation | def get_params_parser():
"""Parse command line arguments"""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-g', '--debug', dest='debug',
action='store_true',
help=argparse.SUPPRESS)
parser.add_argument("--arthur", action='store_tru... | python | {
"resource": ""
} |
q257155 | get_params | validation | def get_params():
"""Get params to execute the micro-mordred"""
parser = get_params_parser()
args = parser.parse_args()
if not args.raw and not args.enrich and not args.identities and not args.panels:
print("No tasks enabled")
sys.exit(1)
return args | python | {
"resource": ""
} |
q257156 | TaskPanels.__kibiter_version | validation | def __kibiter_version(self):
""" Get the kibiter vesion.
:param major: major Elasticsearch version
"""
version = None
es_url = self.conf['es_enrichment']['url']
config_url = '.kibana/config/_search'
url = urijoin(es_url, config_url)
version = None
... | python | {
"resource": ""
} |
q257157 | TaskPanels.create_dashboard | validation | def create_dashboard(self, panel_file, data_sources=None, strict=True):
"""Upload a panel to Elasticsearch if it does not exist yet.
If a list of data sources is specified, upload only those
elements (visualizations, searches) that match that data source.
:param panel_file: file name o... | python | {
"resource": ""
} |
q257158 | TaskPanelsMenu.__upload_title | validation | def __upload_title(self, kibiter_major):
"""Upload to Kibiter the title for the dashboard.
The title is shown on top of the dashboard menu, and is Usually
the name of the project being dashboarded.
This is done only for Kibiter 6.x.
:param kibiter_major: major version of kibite... | python | {
"resource": ""
} |
q257159 | TaskPanelsMenu.__create_dashboard_menu | validation | def __create_dashboard_menu(self, dash_menu, kibiter_major):
"""Create the menu definition to access the panels in a dashboard.
:param menu: dashboard menu to upload
:param kibiter_major: major version of kibiter
"""
logger.info("Adding dashboard menu")
if kibit... | python | {
"resource": ""
} |
q257160 | TaskPanelsMenu.__remove_dashboard_menu | validation | def __remove_dashboard_menu(self, kibiter_major):
"""Remove existing menu for dashboard, if any.
Usually, we remove the menu before creating a new one.
:param kibiter_major: major version of kibiter
"""
logger.info("Removing old dashboard menu, if any")
if kibiter_major... | python | {
"resource": ""
} |
q257161 | TaskPanelsMenu.__get_menu_entries | validation | def __get_menu_entries(self, kibiter_major):
""" Get the menu entries from the panel definition """
menu_entries = []
for entry in self.panels_menu:
if entry['source'] not in self.data_sources:
continue
parent_menu_item = {
'name': entry['n... | python | {
"resource": ""
} |
q257162 | TaskPanelsMenu.__get_dash_menu | validation | def __get_dash_menu(self, kibiter_major):
"""Order the dashboard menu"""
# omenu = OrderedDict()
omenu = []
# Start with Overview
omenu.append(self.menu_panels_common['Overview'])
# Now the data _getsources
ds_menu = self.__get_menu_entries(kibiter_major)
... | python | {
"resource": ""
} |
q257163 | compose_mbox | validation | def compose_mbox(projects):
""" Compose projects.json only for mbox, but using the mailing_lists lists
change: 'https://dev.eclipse.org/mailman/listinfo/emft-dev'
to: 'emfg-dev /home/bitergia/mboxes/emft-dev.mbox/emft-dev.mbox
:param projects: projects.json
:return: projects.json with mbox
"""... | python | {
"resource": ""
} |
q257164 | compose_gerrit | validation | def compose_gerrit(projects):
""" Compose projects.json for gerrit, but using the git lists
change: 'http://git.eclipse.org/gitroot/xwt/org.eclipse.xwt.git'
to: 'git.eclipse.org_xwt/org.eclipse.xwt
:param projects: projects.json
:return: projects.json with gerrit
"""
git_projects = [projec... | python | {
"resource": ""
} |
q257165 | compose_git | validation | def compose_git(projects, data):
""" Compose projects.json for git
We need to replace '/c/' by '/gitroot/' for instance
change: 'http://git.eclipse.org/c/xwt/org.eclipse.xwt.git'
to: 'http://git.eclipse.org/gitroot/xwt/org.eclipse.xwt.git'
:param projects: projects.json
:param data: eclipse J... | python | {
"resource": ""
} |
q257166 | compose_mailing_lists | validation | def compose_mailing_lists(projects, data):
""" Compose projects.json for mailing lists
At upstream has two different key for mailing list: 'mailings_lists' and 'dev_list'
The key 'mailing_lists' is an array with mailing lists
The key 'dev_list' is a dict with only one mailing list
:param projects:... | python | {
"resource": ""
} |
q257167 | compose_github | validation | def compose_github(projects, data):
""" Compose projects.json for github
:param projects: projects.json
:param data: eclipse JSON
:return: projects.json with github
"""
for p in [project for project in data if len(data[project]['github_repos']) > 0]:
if 'github' not in projects[p]:
... | python | {
"resource": ""
} |
q257168 | compose_bugzilla | validation | def compose_bugzilla(projects, data):
""" Compose projects.json for bugzilla
:param projects: projects.json
:param data: eclipse JSON
:return: projects.json with bugzilla
"""
for p in [project for project in data if len(data[project]['bugzilla']) > 0]:
if 'bugzilla' not in projects[p]:
... | python | {
"resource": ""
} |
q257169 | compose_title | validation | def compose_title(projects, data):
""" Compose the projects JSON file only with the projects name
:param projects: projects.json
:param data: eclipse JSON with the origin format
:return: projects.json with titles
"""
for project in data:
projects[project] = {
'meta': {
... | python | {
"resource": ""
} |
q257170 | compose_projects_json | validation | def compose_projects_json(projects, data):
""" Compose projects.json with all data sources
:param projects: projects.json
:param data: eclipse JSON
:return: projects.json with all data sources
"""
projects = compose_git(projects, data)
projects = compose_mailing_lists(projects, data)
pr... | python | {
"resource": ""
} |
q257171 | TaskEnrich.__autorefresh_studies | validation | def __autorefresh_studies(self, cfg):
"""Execute autorefresh for areas of code study if configured"""
if 'studies' not in self.conf[self.backend_section] or \
'enrich_areas_of_code:git' not in self.conf[self.backend_section]['studies']:
logger.debug("Not doing autorefresh fo... | python | {
"resource": ""
} |
q257172 | TaskEnrich.__studies | validation | def __studies(self, retention_time):
""" Execute the studies configured for the current backend """
cfg = self.config.get_conf()
if 'studies' not in cfg[self.backend_section] or not \
cfg[self.backend_section]['studies']:
logger.debug('No studies for %s' % self.backend_se... | python | {
"resource": ""
} |
q257173 | TaskEnrich.retain_identities | validation | def retain_identities(self, retention_time):
"""Retain the identities in SortingHat based on the `retention_time`
value declared in the setup.cfg.
:param retention_time: maximum number of minutes wrt the current date to retain the SortingHat data
"""
enrich_es = self.conf['es_en... | python | {
"resource": ""
} |
q257174 | TaskProjects.get_repos_by_backend_section | validation | def get_repos_by_backend_section(cls, backend_section, raw=True):
""" return list with the repositories for a backend_section """
repos = []
projects = TaskProjects.get_projects()
for pro in projects:
if backend_section in projects[pro]:
# if the projects.jso... | python | {
"resource": ""
} |
q257175 | TaskProjects.convert_from_eclipse | validation | def convert_from_eclipse(self, eclipse_projects):
""" Convert from eclipse projects format to grimoire projects json format """
projects = {}
# We need the global project for downloading the full Bugzilla and Gerrit
projects['unknown'] = {
"gerrit": ["git.eclipse.org"],
... | python | {
"resource": ""
} |
q257176 | Config.set_param | validation | def set_param(self, section, param, value):
""" Change a param in the config """
if section not in self.conf or param not in self.conf[section]:
logger.error('Config section %s and param %s not exists', section, param)
else:
self.conf[section][param] = value | python | {
"resource": ""
} |
q257177 | Config._add_to_conf | validation | def _add_to_conf(self, new_conf):
"""Add new configuration to self.conf.
Adds configuration parameters in new_con to self.conf.
If they already existed in conf, overwrite them.
:param new_conf: new configuration, to add
"""
for section in new_conf:
if secti... | python | {
"resource": ""
} |
q257178 | Task.es_version | validation | def es_version(self, url):
"""Get Elasticsearch version.
Get the version of Elasticsearch. This is useful because
Elasticsearch and Kibiter are paired (same major version for 5, 6).
:param url: Elasticseearch url hosting Kibiter indices
:returns: major version, as string
... | python | {
"resource": ""
} |
q257179 | SirMordred.execute_nonstop_tasks | validation | def execute_nonstop_tasks(self, tasks_cls):
"""
Just a wrapper to the execute_batch_tasks method
"""
self.execute_batch_tasks(tasks_cls,
self.conf['sortinghat']['sleep_for'],
self.conf['general']['min_update_delay'], F... | python | {
"resource": ""
} |
q257180 | SirMordred.execute_batch_tasks | validation | def execute_batch_tasks(self, tasks_cls, big_delay=0, small_delay=0, wait_for_threads=True):
"""
Start a task manager per backend to complete the tasks.
:param task_cls: list of tasks classes to be executed
:param big_delay: seconds before global tasks are executed, should be days usual... | python | {
"resource": ""
} |
q257181 | SirMordred.__execute_initial_load | validation | def __execute_initial_load(self):
"""
Tasks that should be done just one time
"""
if self.conf['phases']['panels']:
tasks_cls = [TaskPanels, TaskPanelsMenu]
self.execute_tasks(tasks_cls)
if self.conf['phases']['identities']:
tasks_cls = [TaskI... | python | {
"resource": ""
} |
q257182 | Config.validate_config | validation | def validate_config(self):
'''
Validates the provided config to make sure all the required fields are
there.
'''
# first ensure that all the required fields are there
for key, key_config in self.params_map.items():
if key_config['required']:
i... | python | {
"resource": ""
} |
q257183 | Result.stdout | validation | def stdout(self):
"""
Converts stdout string to a list.
"""
if self._streaming:
stdout = []
while not self.__stdout.empty():
try:
line = self.__stdout.get_nowait()
stdout.append(line)
except:
... | python | {
"resource": ""
} |
q257184 | Result.stderr | validation | def stderr(self):
"""
Converts stderr string to a list.
"""
if self._streaming:
stderr = []
while not self.__stderr.empty():
try:
line = self.__stderr.get_nowait()
stderr.append(line)
except:
... | python | {
"resource": ""
} |
q257185 | LevelFormatter.format | validation | def format(self, record):
"""Customize the message format based on the log level."""
if isinstance(self.fmt, dict):
self._fmt = self.fmt[record.levelname]
if sys.version_info > (3, 2):
# Update self._style because we've changed self._fmt
# (code ba... | python | {
"resource": ""
} |
q257186 | replace_print | validation | def replace_print(fileobj=sys.stderr):
"""Sys.out replacer, by default with stderr.
Use it like this:
with replace_print_with(fileobj):
print "hello" # writes to the file
print "done" # prints to stdout
Args:
fileobj: a file object to replace stdout.
Yields:
The printer.
"""
printer = _... | python | {
"resource": ""
} |
q257187 | compact_interval_string | validation | def compact_interval_string(value_list):
"""Compact a list of integers into a comma-separated string of intervals.
Args:
value_list: A list of sortable integers such as a list of numbers
Returns:
A compact string representation, such as "1-5,8,12-15"
"""
if not value_list:
return ''
value_li... | python | {
"resource": ""
} |
q257188 | _get_storage_service | validation | def _get_storage_service(credentials):
"""Get a storage client using the provided credentials or defaults."""
if credentials is None:
credentials = oauth2client.client.GoogleCredentials.get_application_default(
)
return discovery.build('storage', 'v1', credentials=credentials) | python | {
"resource": ""
} |
q257189 | _retry_storage_check | validation | def _retry_storage_check(exception):
"""Return True if we should retry, False otherwise."""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
print_error(
'%s: Exception %s: %s' % (now, type(exception).__name__, str(exception)))
return isinstance(exception, oauth2client.client.AccessTokenRefreshError) | python | {
"resource": ""
} |
q257190 | _load_file_from_gcs | validation | def _load_file_from_gcs(gcs_file_path, credentials=None):
"""Load context from a text file in gcs.
Args:
gcs_file_path: The target file path; should have the 'gs://' prefix.
credentials: Optional credential to be used to load the file from gcs.
Returns:
The content of the text file as a string.
""... | python | {
"resource": ""
} |
q257191 | load_file | validation | def load_file(file_path, credentials=None):
"""Load a file from either local or gcs.
Args:
file_path: The target file path, which should have the prefix 'gs://' if
to be loaded from gcs.
credentials: Optional credential to be used to load the file from gcs.
Returns:
A python File obje... | python | {
"resource": ""
} |
q257192 | _file_exists_in_gcs | validation | def _file_exists_in_gcs(gcs_file_path, credentials=None):
"""Check whether the file exists, in GCS.
Args:
gcs_file_path: The target file path; should have the 'gs://' prefix.
credentials: Optional credential to be used to load the file from gcs.
Returns:
True if the file's there.
"""
gcs_service... | python | {
"resource": ""
} |
q257193 | file_exists | validation | def file_exists(file_path, credentials=None):
"""Check whether the file exists, on local disk or GCS.
Args:
file_path: The target file path; should have the 'gs://' prefix if in gcs.
credentials: Optional credential to be used to load the file from gcs.
Returns:
True if the file's there.
"""
if ... | python | {
"resource": ""
} |
q257194 | _prefix_exists_in_gcs | validation | def _prefix_exists_in_gcs(gcs_prefix, credentials=None):
"""Check whether there is a GCS object whose name starts with the prefix.
Since GCS doesn't actually have folders, this is how we check instead.
Args:
gcs_prefix: The path; should start with 'gs://'.
credentials: Optional credential to be used to ... | python | {
"resource": ""
} |
q257195 | simple_pattern_exists_in_gcs | validation | def simple_pattern_exists_in_gcs(file_pattern, credentials=None):
"""True iff an object exists matching the input GCS pattern.
The GCS pattern must be a full object reference or a "simple pattern" that
conforms to the dsub input and output parameter restrictions:
* No support for **, ? wildcards or [] chara... | python | {
"resource": ""
} |
q257196 | outputs_are_present | validation | def outputs_are_present(outputs):
"""True if each output contains at least one file or no output specified."""
# outputs are OutputFileParam (see param_util.py)
# If outputs contain a pattern, then there is no way for `dsub` to verify
# that *all* output is present. The best that `dsub` can do is to verify
#... | python | {
"resource": ""
} |
q257197 | _Pipelines._build_pipeline_input_file_param | validation | def _build_pipeline_input_file_param(cls, var_name, docker_path):
"""Return a dict object representing a pipeline input argument."""
# If the filename contains a wildcard, then the target Docker path must
# be a directory in order to ensure consistency whether the source pattern
# contains 1 or multipl... | python | {
"resource": ""
} |
q257198 | _Pipelines._build_pipeline_docker_command | validation | def _build_pipeline_docker_command(cls, script_name, inputs, outputs, envs):
"""Return a multi-line string of the full pipeline docker command."""
# We upload the user script as an environment argument
# and write it to SCRIPT_DIR (preserving its local file name).
#
# The docker_command:
# * wr... | python | {
"resource": ""
} |
q257199 | _Pipelines.build_pipeline | validation | def build_pipeline(cls, project, zones, min_cores, min_ram, disk_size,
boot_disk_size, preemptible, accelerator_type,
accelerator_count, image, script_name, envs, inputs,
outputs, pipeline_name):
"""Builds a pipeline configuration for execution.
Ar... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.