repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
genialis/resolwe
resolwe/elastic/builder.py
Dependency.connect
def connect(self, index): """Connect signals needed for dependency updates. Pre- and post-delete signals have to be handled separately, as: * in the pre-delete signal we have the information which objects to rebuild, but affected relations are still presented, so rebu...
python
def connect(self, index): """Connect signals needed for dependency updates. Pre- and post-delete signals have to be handled separately, as: * in the pre-delete signal we have the information which objects to rebuild, but affected relations are still presented, so rebu...
[ "def", "connect", "(", "self", ",", "index", ")", ":", "self", ".", "index", "=", "index", "signal", "=", "ElasticSignal", "(", "self", ",", "'process'", ",", "pass_kwargs", "=", "True", ")", "signal", ".", "connect", "(", "post_save", ",", "sender", "...
Connect signals needed for dependency updates. Pre- and post-delete signals have to be handled separately, as: * in the pre-delete signal we have the information which objects to rebuild, but affected relations are still presented, so rebuild would reflect in the wrong (outda...
[ "Connect", "signals", "needed", "for", "dependency", "updates", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L148-L177
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.connect
def connect(self, index): """Connect signals needed for dependency updates.""" # Determine which model is the target model as either side of the relation # may be passed as `field`. if index.object_type == self.field.rel.model: self.model = self.field.rel.related_model ...
python
def connect(self, index): """Connect signals needed for dependency updates.""" # Determine which model is the target model as either side of the relation # may be passed as `field`. if index.object_type == self.field.rel.model: self.model = self.field.rel.related_model ...
[ "def", "connect", "(", "self", ",", "index", ")", ":", "# Determine which model is the target model as either side of the relation", "# may be passed as `field`.", "if", "index", ".", "object_type", "==", "self", ".", "field", ".", "rel", ".", "model", ":", "self", "....
Connect signals needed for dependency updates.
[ "Connect", "signals", "needed", "for", "dependency", "updates", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L207-L248
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency._filter
def _filter(self, objects, **kwargs): """Determine if dependent object should be processed.""" for obj in objects: if self.filter(obj, **kwargs) is False: return False return True
python
def _filter(self, objects, **kwargs): """Determine if dependent object should be processed.""" for obj in objects: if self.filter(obj, **kwargs) is False: return False return True
[ "def", "_filter", "(", "self", ",", "objects", ",", "*", "*", "kwargs", ")", ":", "for", "obj", "in", "objects", ":", "if", "self", ".", "filter", "(", "obj", ",", "*", "*", "kwargs", ")", "is", "False", ":", "return", "False", "return", "True" ]
Determine if dependent object should be processed.
[ "Determine", "if", "dependent", "object", "should", "be", "processed", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L257-L263
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency._get_build_kwargs
def _get_build_kwargs(self, obj, pk_set=None, action=None, update_fields=None, reverse=None, **kwargs): """Prepare arguments for rebuilding indices.""" if action is None: # Check filter before rebuilding index. if not self._filter([obj], update_fields=update_fields): ...
python
def _get_build_kwargs(self, obj, pk_set=None, action=None, update_fields=None, reverse=None, **kwargs): """Prepare arguments for rebuilding indices.""" if action is None: # Check filter before rebuilding index. if not self._filter([obj], update_fields=update_fields): ...
[ "def", "_get_build_kwargs", "(", "self", ",", "obj", ",", "pk_set", "=", "None", ",", "action", "=", "None", ",", "update_fields", "=", "None", ",", "reverse", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "action", "is", "None", ":", "# Chec...
Prepare arguments for rebuilding indices.
[ "Prepare", "arguments", "for", "rebuilding", "indices", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L265-L303
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.process_predelete
def process_predelete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Render the queryset of influenced objects and cache it.""" build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs) self.delete_cache.set(obj, build_kwargs)
python
def process_predelete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Render the queryset of influenced objects and cache it.""" build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs) self.delete_cache.set(obj, build_kwargs)
[ "def", "process_predelete", "(", "self", ",", "obj", ",", "pk_set", "=", "None", ",", "action", "=", "None", ",", "update_fields", "=", "None", ",", "*", "*", "kwargs", ")", ":", "build_kwargs", "=", "self", ".", "_get_build_kwargs", "(", "obj", ",", "...
Render the queryset of influenced objects and cache it.
[ "Render", "the", "queryset", "of", "influenced", "objects", "and", "cache", "it", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L305-L308
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.process_delete
def process_delete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Recreate queryset from the index and rebuild the index.""" build_kwargs = self.delete_cache.take(obj) if build_kwargs: self.index.build(**build_kwargs)
python
def process_delete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Recreate queryset from the index and rebuild the index.""" build_kwargs = self.delete_cache.take(obj) if build_kwargs: self.index.build(**build_kwargs)
[ "def", "process_delete", "(", "self", ",", "obj", ",", "pk_set", "=", "None", ",", "action", "=", "None", ",", "update_fields", "=", "None", ",", "*", "*", "kwargs", ")", ":", "build_kwargs", "=", "self", ".", "delete_cache", ".", "take", "(", "obj", ...
Recreate queryset from the index and rebuild the index.
[ "Recreate", "queryset", "from", "the", "index", "and", "rebuild", "the", "index", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L310-L315
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.process_m2m
def process_m2m(self, obj, pk_set=None, action=None, update_fields=None, cache_key=None, **kwargs): """Process signals from dependencies. Remove signal is processed in two parts. For details see: :func:`~Dependency.connect` """ if action not in (None, 'post_add', 'pre_remove', '...
python
def process_m2m(self, obj, pk_set=None, action=None, update_fields=None, cache_key=None, **kwargs): """Process signals from dependencies. Remove signal is processed in two parts. For details see: :func:`~Dependency.connect` """ if action not in (None, 'post_add', 'pre_remove', '...
[ "def", "process_m2m", "(", "self", ",", "obj", ",", "pk_set", "=", "None", ",", "action", "=", "None", ",", "update_fields", "=", "None", ",", "cache_key", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "action", "not", "in", "(", "None", ",...
Process signals from dependencies. Remove signal is processed in two parts. For details see: :func:`~Dependency.connect`
[ "Process", "signals", "from", "dependencies", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L317-L336
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency._process_m2m_through
def _process_m2m_through(self, obj, action): """Process custom M2M through model actions.""" source = getattr(obj, self.field.rel.field.m2m_field_name()) target = getattr(obj, self.field.rel.field.m2m_reverse_field_name()) pk_set = set() if target: pk_set.add(target....
python
def _process_m2m_through(self, obj, action): """Process custom M2M through model actions.""" source = getattr(obj, self.field.rel.field.m2m_field_name()) target = getattr(obj, self.field.rel.field.m2m_reverse_field_name()) pk_set = set() if target: pk_set.add(target....
[ "def", "_process_m2m_through", "(", "self", ",", "obj", ",", "action", ")", ":", "source", "=", "getattr", "(", "obj", ",", "self", ".", "field", ".", "rel", ".", "field", ".", "m2m_field_name", "(", ")", ")", "target", "=", "getattr", "(", "obj", ",...
Process custom M2M through model actions.
[ "Process", "custom", "M2M", "through", "model", "actions", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L338-L347
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.process_m2m_through_save
def process_m2m_through_save(self, obj, created=False, **kwargs): """Process M2M post save for custom through model.""" # We are only interested in signals that establish relations. if not created: return self._process_m2m_through(obj, 'post_add')
python
def process_m2m_through_save(self, obj, created=False, **kwargs): """Process M2M post save for custom through model.""" # We are only interested in signals that establish relations. if not created: return self._process_m2m_through(obj, 'post_add')
[ "def", "process_m2m_through_save", "(", "self", ",", "obj", ",", "created", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# We are only interested in signals that establish relations.", "if", "not", "created", ":", "return", "self", ".", "_process_m2m_through", ...
Process M2M post save for custom through model.
[ "Process", "M2M", "post", "save", "for", "custom", "through", "model", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L349-L355
genialis/resolwe
resolwe/elastic/builder.py
ManyToManyDependency.process
def process(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Process signals from dependencies.""" build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs) if build_kwargs: self.index.build(**build_kwargs)
python
def process(self, obj, pk_set=None, action=None, update_fields=None, **kwargs): """Process signals from dependencies.""" build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs) if build_kwargs: self.index.build(**build_kwargs)
[ "def", "process", "(", "self", ",", "obj", ",", "pk_set", "=", "None", ",", "action", "=", "None", ",", "update_fields", "=", "None", ",", "*", "*", "kwargs", ")", ":", "build_kwargs", "=", "self", ".", "_get_build_kwargs", "(", "obj", ",", "pk_set", ...
Process signals from dependencies.
[ "Process", "signals", "from", "dependencies", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L365-L370
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder._connect_signal
def _connect_signal(self, index): """Create signals for building indexes.""" post_save_signal = ElasticSignal(index, 'build') post_save_signal.connect(post_save, sender=index.object_type) self.signals.append(post_save_signal) post_delete_signal = ElasticSignal(index, 'remove_obj...
python
def _connect_signal(self, index): """Create signals for building indexes.""" post_save_signal = ElasticSignal(index, 'build') post_save_signal.connect(post_save, sender=index.object_type) self.signals.append(post_save_signal) post_delete_signal = ElasticSignal(index, 'remove_obj...
[ "def", "_connect_signal", "(", "self", ",", "index", ")", ":", "post_save_signal", "=", "ElasticSignal", "(", "index", ",", "'build'", ")", "post_save_signal", ".", "connect", "(", "post_save", ",", "sender", "=", "index", ".", "object_type", ")", "self", "....
Create signals for building indexes.
[ "Create", "signals", "for", "building", "indexes", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L397-L416
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.register_signals
def register_signals(self): """Register signals for all indexes.""" for index in self.indexes: if index.object_type: self._connect_signal(index)
python
def register_signals(self): """Register signals for all indexes.""" for index in self.indexes: if index.object_type: self._connect_signal(index)
[ "def", "register_signals", "(", "self", ")", ":", "for", "index", "in", "self", ".", "indexes", ":", "if", "index", ".", "object_type", ":", "self", ".", "_connect_signal", "(", "index", ")" ]
Register signals for all indexes.
[ "Register", "signals", "for", "all", "indexes", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L424-L428
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.discover_indexes
def discover_indexes(self): """Save list of index builders into ``_index_builders``.""" self.indexes = [] for app_config in apps.get_app_configs(): indexes_path = '{}.elastic_indexes'.format(app_config.name) try: indexes_module = import_module(indexes_pat...
python
def discover_indexes(self): """Save list of index builders into ``_index_builders``.""" self.indexes = [] for app_config in apps.get_app_configs(): indexes_path = '{}.elastic_indexes'.format(app_config.name) try: indexes_module = import_module(indexes_pat...
[ "def", "discover_indexes", "(", "self", ")", ":", "self", ".", "indexes", "=", "[", "]", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ")", ":", "indexes_path", "=", "'{}.elastic_indexes'", ".", "format", "(", "app_config", ".", "name", "...
Save list of index builders into ``_index_builders``.
[ "Save", "list", "of", "index", "builders", "into", "_index_builders", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L435-L472
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.build
def build(self, obj=None, queryset=None, push=True): """Trigger building of the indexes. Support passing ``obj`` parameter to the indexes, so we can trigger build only for one object. """ for index in self.indexes: index.build(obj, queryset, push)
python
def build(self, obj=None, queryset=None, push=True): """Trigger building of the indexes. Support passing ``obj`` parameter to the indexes, so we can trigger build only for one object. """ for index in self.indexes: index.build(obj, queryset, push)
[ "def", "build", "(", "self", ",", "obj", "=", "None", ",", "queryset", "=", "None", ",", "push", "=", "True", ")", ":", "for", "index", "in", "self", ".", "indexes", ":", "index", ".", "build", "(", "obj", ",", "queryset", ",", "push", ")" ]
Trigger building of the indexes. Support passing ``obj`` parameter to the indexes, so we can trigger build only for one object.
[ "Trigger", "building", "of", "the", "indexes", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L474-L481
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.push
def push(self, index=None): """Push built documents to ElasticSearch. If ``index`` is specified, only that index will be pushed. """ for ind in self.indexes: if index and not isinstance(ind, index): continue ind.push()
python
def push(self, index=None): """Push built documents to ElasticSearch. If ``index`` is specified, only that index will be pushed. """ for ind in self.indexes: if index and not isinstance(ind, index): continue ind.push()
[ "def", "push", "(", "self", ",", "index", "=", "None", ")", ":", "for", "ind", "in", "self", ".", "indexes", ":", "if", "index", "and", "not", "isinstance", "(", "ind", ",", "index", ")", ":", "continue", "ind", ".", "push", "(", ")" ]
Push built documents to ElasticSearch. If ``index`` is specified, only that index will be pushed.
[ "Push", "built", "documents", "to", "ElasticSearch", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L483-L491
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.delete
def delete(self, skip_mapping=False): """Delete all entries from ElasticSearch.""" for index in self.indexes: index.destroy() if not skip_mapping: index.create_mapping()
python
def delete(self, skip_mapping=False): """Delete all entries from ElasticSearch.""" for index in self.indexes: index.destroy() if not skip_mapping: index.create_mapping()
[ "def", "delete", "(", "self", ",", "skip_mapping", "=", "False", ")", ":", "for", "index", "in", "self", ".", "indexes", ":", "index", ".", "destroy", "(", ")", "if", "not", "skip_mapping", ":", "index", ".", "create_mapping", "(", ")" ]
Delete all entries from ElasticSearch.
[ "Delete", "all", "entries", "from", "ElasticSearch", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L493-L498
genialis/resolwe
resolwe/elastic/builder.py
IndexBuilder.destroy
def destroy(self): """Delete all indexes from Elasticsearch and index builder.""" self.unregister_signals() for index in self.indexes: index.destroy() self.indexes = []
python
def destroy(self): """Delete all indexes from Elasticsearch and index builder.""" self.unregister_signals() for index in self.indexes: index.destroy() self.indexes = []
[ "def", "destroy", "(", "self", ")", ":", "self", ".", "unregister_signals", "(", ")", "for", "index", "in", "self", ".", "indexes", ":", "index", ".", "destroy", "(", ")", "self", ".", "indexes", "=", "[", "]" ]
Delete all indexes from Elasticsearch and index builder.
[ "Delete", "all", "indexes", "from", "Elasticsearch", "and", "index", "builder", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L505-L510
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._set_initial
def _set_initial(self, C_in, scale_in): r"""Set the initial values for parameters and Wilson coefficients at the scale `scale_in`.""" self.C_in = C_in self.scale_in = scale_in
python
def _set_initial(self, C_in, scale_in): r"""Set the initial values for parameters and Wilson coefficients at the scale `scale_in`.""" self.C_in = C_in self.scale_in = scale_in
[ "def", "_set_initial", "(", "self", ",", "C_in", ",", "scale_in", ")", ":", "self", ".", "C_in", "=", "C_in", "self", ".", "scale_in", "=", "scale_in" ]
r"""Set the initial values for parameters and Wilson coefficients at the scale `scale_in`.
[ "r", "Set", "the", "initial", "values", "for", "parameters", "and", "Wilson", "coefficients", "at", "the", "scale", "scale_in", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L37-L41
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._set_initial_wcxf
def _set_initial_wcxf(self, wc, get_smpar=True): """Load the initial values for Wilson coefficients from a wcxf.WC instance. Parameters: - `get_smpar`: boolean, optional, defaults to True. If True, an attempt is made to determine the SM parameters from the requirement of ...
python
def _set_initial_wcxf(self, wc, get_smpar=True): """Load the initial values for Wilson coefficients from a wcxf.WC instance. Parameters: - `get_smpar`: boolean, optional, defaults to True. If True, an attempt is made to determine the SM parameters from the requirement of ...
[ "def", "_set_initial_wcxf", "(", "self", ",", "wc", ",", "get_smpar", "=", "True", ")", ":", "if", "wc", ".", "eft", "!=", "'SMEFT'", ":", "raise", "ValueError", "(", "\"Wilson coefficients use wrong EFT.\"", ")", "if", "wc", ".", "basis", "!=", "'Warsaw'", ...
Load the initial values for Wilson coefficients from a wcxf.WC instance. Parameters: - `get_smpar`: boolean, optional, defaults to True. If True, an attempt is made to determine the SM parameters from the requirement of reproducing the correct SM masses and mixings at the e...
[ "Load", "the", "initial", "values", "for", "Wilson", "coefficients", "from", "a", "wcxf", ".", "WC", "instance", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L43-L78
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._to_wcxf
def _to_wcxf(self, C_out, scale_out): """Return the Wilson coefficients `C_out` as a wcxf.WC instance. Note that the Wilson coefficients are rotated into the Warsaw basis as defined in WCxf, i.e. to the basis where the down-type and charged lepton mass matrices are diagonal.""" ...
python
def _to_wcxf(self, C_out, scale_out): """Return the Wilson coefficients `C_out` as a wcxf.WC instance. Note that the Wilson coefficients are rotated into the Warsaw basis as defined in WCxf, i.e. to the basis where the down-type and charged lepton mass matrices are diagonal.""" ...
[ "def", "_to_wcxf", "(", "self", ",", "C_out", ",", "scale_out", ")", ":", "C", "=", "self", ".", "_rotate_defaultbasis", "(", "C_out", ")", "d", "=", "wilson", ".", "util", ".", "smeftutil", ".", "arrays2wcxf_nonred", "(", "C", ")", "basis", "=", "wcxf...
Return the Wilson coefficients `C_out` as a wcxf.WC instance. Note that the Wilson coefficients are rotated into the Warsaw basis as defined in WCxf, i.e. to the basis where the down-type and charged lepton mass matrices are diagonal.
[ "Return", "the", "Wilson", "coefficients", "C_out", "as", "a", "wcxf", ".", "WC", "instance", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L80-L93
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._rgevolve
def _rgevolve(self, scale_out, **kwargs): """Solve the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients at `scale_out`. Additional keyword arguments will be passed to the ODE solver `scipy.integrate.odeint`.""" self._c...
python
def _rgevolve(self, scale_out, **kwargs): """Solve the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients at `scale_out`. Additional keyword arguments will be passed to the ODE solver `scipy.integrate.odeint`.""" self._c...
[ "def", "_rgevolve", "(", "self", ",", "scale_out", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_initial", "(", ")", "return", "rge", ".", "smeft_evolve", "(", "C_in", "=", "self", ".", "C_in", ",", "scale_in", "=", "self", ".", "scale_in", ...
Solve the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients at `scale_out`. Additional keyword arguments will be passed to the ODE solver `scipy.integrate.odeint`.
[ "Solve", "the", "SMEFT", "RGEs", "from", "the", "initial", "scale", "to", "scale_out", ".", "Returns", "a", "dictionary", "with", "parameters", "and", "Wilson", "coefficients", "at", "scale_out", ".", "Additional", "keyword", "arguments", "will", "be", "passed",...
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L95-L104
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._rgevolve_leadinglog
def _rgevolve_leadinglog(self, scale_out): """Compute the leading logarithmic approximation to the solution of the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients. Much faster but less precise that `rgevolve`. """ ...
python
def _rgevolve_leadinglog(self, scale_out): """Compute the leading logarithmic approximation to the solution of the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients. Much faster but less precise that `rgevolve`. """ ...
[ "def", "_rgevolve_leadinglog", "(", "self", ",", "scale_out", ")", ":", "self", ".", "_check_initial", "(", ")", "return", "rge", ".", "smeft_evolve_leadinglog", "(", "C_in", "=", "self", ".", "C_in", ",", "scale_in", "=", "self", ".", "scale_in", ",", "sc...
Compute the leading logarithmic approximation to the solution of the SMEFT RGEs from the initial scale to `scale_out`. Returns a dictionary with parameters and Wilson coefficients. Much faster but less precise that `rgevolve`.
[ "Compute", "the", "leading", "logarithmic", "approximation", "to", "the", "solution", "of", "the", "SMEFT", "RGEs", "from", "the", "initial", "scale", "to", "scale_out", ".", "Returns", "a", "dictionary", "with", "parameters", "and", "Wilson", "coefficients", "....
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L106-L115
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._run_sm_scale_in
def _run_sm_scale_in(self, C_out, scale_sm=91.1876): """Get the SM parameters at the EW scale, using an estimate `C_out` of the Wilson coefficients at that scale, and run them to the input scale.""" # initialize an empty SMEFT instance smeft_sm = SMEFT(wc=None) C_in_sm = ...
python
def _run_sm_scale_in(self, C_out, scale_sm=91.1876): """Get the SM parameters at the EW scale, using an estimate `C_out` of the Wilson coefficients at that scale, and run them to the input scale.""" # initialize an empty SMEFT instance smeft_sm = SMEFT(wc=None) C_in_sm = ...
[ "def", "_run_sm_scale_in", "(", "self", ",", "C_out", ",", "scale_sm", "=", "91.1876", ")", ":", "# initialize an empty SMEFT instance", "smeft_sm", "=", "SMEFT", "(", "wc", "=", "None", ")", "C_in_sm", "=", "smeftutil", ".", "C_array2dict", "(", "np", ".", ...
Get the SM parameters at the EW scale, using an estimate `C_out` of the Wilson coefficients at that scale, and run them to the input scale.
[ "Get", "the", "SM", "parameters", "at", "the", "EW", "scale", "using", "an", "estimate", "C_out", "of", "the", "Wilson", "coefficients", "at", "that", "scale", "and", "run", "them", "to", "the", "input", "scale", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L144-L162
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT.get_smpar
def get_smpar(self, accuracy='integrate', scale_sm=91.1876): """Compute the SM MS-bar parameters at the electroweak scale. This method can be used to validate the accuracy of the iterative extraction of SM parameters. If successful, the values returned by this method should agree with t...
python
def get_smpar(self, accuracy='integrate', scale_sm=91.1876): """Compute the SM MS-bar parameters at the electroweak scale. This method can be used to validate the accuracy of the iterative extraction of SM parameters. If successful, the values returned by this method should agree with t...
[ "def", "get_smpar", "(", "self", ",", "accuracy", "=", "'integrate'", ",", "scale_sm", "=", "91.1876", ")", ":", "if", "accuracy", "==", "'integrate'", ":", "C_out", "=", "self", ".", "_rgevolve", "(", "scale_sm", ")", "elif", "accuracy", "==", "'leadinglo...
Compute the SM MS-bar parameters at the electroweak scale. This method can be used to validate the accuracy of the iterative extraction of SM parameters. If successful, the values returned by this method should agree with the values in the dictionary `wilson.run.smeft.smpar.p`.
[ "Compute", "the", "SM", "MS", "-", "bar", "parameters", "at", "the", "electroweak", "scale", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L164-L177
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT._get_sm_scale_in
def _get_sm_scale_in(self, scale_sm=91.1876): """Get an estimate of the SM parameters at the input scale by running them from the EW scale using constant values for the Wilson coefficients (corresponding to their leading log approximated values at the EW scale). Note that this i...
python
def _get_sm_scale_in(self, scale_sm=91.1876): """Get an estimate of the SM parameters at the input scale by running them from the EW scale using constant values for the Wilson coefficients (corresponding to their leading log approximated values at the EW scale). Note that this i...
[ "def", "_get_sm_scale_in", "(", "self", ",", "scale_sm", "=", "91.1876", ")", ":", "# intialize a copy of ourselves", "_smeft", "=", "SMEFT", "(", "self", ".", "wc", ",", "get_smpar", "=", "False", ")", "# Step 1: run the SM up, using the WCs at scale_input as (constant...
Get an estimate of the SM parameters at the input scale by running them from the EW scale using constant values for the Wilson coefficients (corresponding to their leading log approximated values at the EW scale). Note that this is not guaranteed to work and will fail if some of the ...
[ "Get", "an", "estimate", "of", "the", "SM", "parameters", "at", "the", "input", "scale", "by", "running", "them", "from", "the", "EW", "scale", "using", "constant", "values", "for", "the", "Wilson", "coefficients", "(", "corresponding", "to", "their", "leadi...
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L179-L195
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT.run
def run(self, scale, accuracy='integrate', **kwargs): """Return the Wilson coefficients (as wcxf.WC instance) evolved to the scale `scale`. Parameters: - `scale`: scale in GeV - accuracy: whether to use the numerical solution to the RGE ('integrate', the default, slow ...
python
def run(self, scale, accuracy='integrate', **kwargs): """Return the Wilson coefficients (as wcxf.WC instance) evolved to the scale `scale`. Parameters: - `scale`: scale in GeV - accuracy: whether to use the numerical solution to the RGE ('integrate', the default, slow ...
[ "def", "run", "(", "self", ",", "scale", ",", "accuracy", "=", "'integrate'", ",", "*", "*", "kwargs", ")", ":", "if", "accuracy", "==", "'integrate'", ":", "C_out", "=", "self", ".", "_rgevolve", "(", "scale", ",", "*", "*", "kwargs", ")", "elif", ...
Return the Wilson coefficients (as wcxf.WC instance) evolved to the scale `scale`. Parameters: - `scale`: scale in GeV - accuracy: whether to use the numerical solution to the RGE ('integrate', the default, slow but precise) or the leading logarithmic approximation ('l...
[ "Return", "the", "Wilson", "coefficients", "(", "as", "wcxf", ".", "WC", "instance", ")", "evolved", "to", "the", "scale", "scale", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L197-L214
wilson-eft/wilson
wilson/run/smeft/classes.py
SMEFT.run_continuous
def run_continuous(self, scale): """Return a continuous solution to the RGE as `RGsolution` instance.""" if scale == self.scale_in: raise ValueError("The scale must be different from the input scale") elif scale < self.scale_in: scale_min = scale scale_max = s...
python
def run_continuous(self, scale): """Return a continuous solution to the RGE as `RGsolution` instance.""" if scale == self.scale_in: raise ValueError("The scale must be different from the input scale") elif scale < self.scale_in: scale_min = scale scale_max = s...
[ "def", "run_continuous", "(", "self", ",", "scale", ")", ":", "if", "scale", "==", "self", ".", "scale_in", ":", "raise", "ValueError", "(", "\"The scale must be different from the input scale\"", ")", "elif", "scale", "<", "self", ".", "scale_in", ":", "scale_m...
Return a continuous solution to the RGE as `RGsolution` instance.
[ "Return", "a", "continuous", "solution", "to", "the", "RGE", "as", "RGsolution", "instance", "." ]
train
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L216-L229
genialis/resolwe
resolwe/flow/models/fields.py
ResolweSlugField.deconstruct
def deconstruct(self): """Deconstruct method.""" name, path, args, kwargs = super().deconstruct() if self.populate_from is not None: kwargs['populate_from'] = self.populate_from if self.unique_with != (): kwargs['unique_with'] = self.unique_with kwar...
python
def deconstruct(self): """Deconstruct method.""" name, path, args, kwargs = super().deconstruct() if self.populate_from is not None: kwargs['populate_from'] = self.populate_from if self.unique_with != (): kwargs['unique_with'] = self.unique_with kwar...
[ "def", "deconstruct", "(", "self", ")", ":", "name", ",", "path", ",", "args", ",", "kwargs", "=", "super", "(", ")", ".", "deconstruct", "(", ")", "if", "self", ".", "populate_from", "is", "not", "None", ":", "kwargs", "[", "'populate_from'", "]", "...
Deconstruct method.
[ "Deconstruct", "method", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/fields.py#L30-L41
genialis/resolwe
resolwe/flow/models/fields.py
ResolweSlugField._get_unique_constraints
def _get_unique_constraints(self, instance): """Return SQL filter for filtering by fields in ``unique_with`` attribute. Filter is returned as tuple of two elements where first one is placeholder which is safe to insert into SQL query and second one may include potentially dangerous valu...
python
def _get_unique_constraints(self, instance): """Return SQL filter for filtering by fields in ``unique_with`` attribute. Filter is returned as tuple of two elements where first one is placeholder which is safe to insert into SQL query and second one may include potentially dangerous valu...
[ "def", "_get_unique_constraints", "(", "self", ",", "instance", ")", ":", "constraints_expression", "=", "[", "]", "constraints_values", "=", "{", "}", "for", "field_name", "in", "self", ".", "unique_with", ":", "if", "constants", ".", "LOOKUP_SEP", "in", "fie...
Return SQL filter for filtering by fields in ``unique_with`` attribute. Filter is returned as tuple of two elements where first one is placeholder which is safe to insert into SQL query and second one may include potentially dangerous values and must be passed to SQL query in ``params``...
[ "Return", "SQL", "filter", "for", "filtering", "by", "fields", "in", "unique_with", "attribute", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/fields.py#L43-L77
genialis/resolwe
resolwe/flow/models/fields.py
ResolweSlugField._get_populate_from_value
def _get_populate_from_value(self, instance): """Get the value from ``populate_from`` attribute.""" if hasattr(self.populate_from, '__call__'): # ResolweSlugField(populate_from=lambda instance: ...) return self.populate_from(instance) else: # ResolweSlugField(...
python
def _get_populate_from_value(self, instance): """Get the value from ``populate_from`` attribute.""" if hasattr(self.populate_from, '__call__'): # ResolweSlugField(populate_from=lambda instance: ...) return self.populate_from(instance) else: # ResolweSlugField(...
[ "def", "_get_populate_from_value", "(", "self", ",", "instance", ")", ":", "if", "hasattr", "(", "self", ".", "populate_from", ",", "'__call__'", ")", ":", "# ResolweSlugField(populate_from=lambda instance: ...)", "return", "self", ".", "populate_from", "(", "instance...
Get the value from ``populate_from`` attribute.
[ "Get", "the", "value", "from", "populate_from", "attribute", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/fields.py#L79-L87
genialis/resolwe
resolwe/flow/models/fields.py
ResolweSlugField.pre_save
def pre_save(self, instance, add): """Ensure slug uniqunes before save.""" slug = self.value_from_object(instance) # We don't want to change slug defined by user. predefined_slug = bool(slug) if not slug and self.populate_from: slug = self._get_populate_from_value(i...
python
def pre_save(self, instance, add): """Ensure slug uniqunes before save.""" slug = self.value_from_object(instance) # We don't want to change slug defined by user. predefined_slug = bool(slug) if not slug and self.populate_from: slug = self._get_populate_from_value(i...
[ "def", "pre_save", "(", "self", ",", "instance", ",", "add", ")", ":", "slug", "=", "self", ".", "value_from_object", "(", "instance", ")", "# We don't want to change slug defined by user.", "predefined_slug", "=", "bool", "(", "slug", ")", "if", "not", "slug", ...
Ensure slug uniqunes before save.
[ "Ensure", "slug", "uniqunes", "before", "save", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/fields.py#L89-L194
genialis/resolwe
resolwe/flow/execution_engines/workflow/__init__.py
ExecutionEngine.discover_process
def discover_process(self, path): """Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas. """ if not path.lower().endswith(('.yml', '.yaml')): ...
python
def discover_process(self, path): """Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas. """ if not path.lower().endswith(('.yml', '.yaml')): ...
[ "def", "discover_process", "(", "self", ",", "path", ")", ":", "if", "not", "path", ".", "lower", "(", ")", ".", "endswith", "(", "(", "'.yml'", ",", "'.yaml'", ")", ")", ":", "return", "[", "]", "with", "open", "(", "path", ")", "as", "fn", ":",...
Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas.
[ "Perform", "process", "discovery", "in", "given", "path", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/workflow/__init__.py#L20-L48
genialis/resolwe
resolwe/flow/execution_engines/workflow/__init__.py
ExecutionEngine._evaluate_expressions
def _evaluate_expressions(self, expression_engine, step_id, values, context): """Recursively evaluate expressions in a dictionary of values.""" if expression_engine is None: return values processed = {} for name, value in values.items(): if isinstance(value, str)...
python
def _evaluate_expressions(self, expression_engine, step_id, values, context): """Recursively evaluate expressions in a dictionary of values.""" if expression_engine is None: return values processed = {} for name, value in values.items(): if isinstance(value, str)...
[ "def", "_evaluate_expressions", "(", "self", ",", "expression_engine", ",", "step_id", ",", "values", ",", "context", ")", ":", "if", "expression_engine", "is", "None", ":", "return", "values", "processed", "=", "{", "}", "for", "name", ",", "value", "in", ...
Recursively evaluate expressions in a dictionary of values.
[ "Recursively", "evaluate", "expressions", "in", "a", "dictionary", "of", "values", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/workflow/__init__.py#L56-L82
genialis/resolwe
resolwe/flow/execution_engines/workflow/__init__.py
ExecutionEngine.evaluate
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" expression_engine = data.process.requirements.get('expression-engine', None) if expression_engine is not None: expression_engine = self.get_expression_engine(expression_engine) # Parse s...
python
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" expression_engine = data.process.requirements.get('expression-engine', None) if expression_engine is not None: expression_engine = self.get_expression_engine(expression_engine) # Parse s...
[ "def", "evaluate", "(", "self", ",", "data", ")", ":", "expression_engine", "=", "data", ".", "process", ".", "requirements", ".", "get", "(", "'expression-engine'", ",", "None", ")", "if", "expression_engine", "is", "not", "None", ":", "expression_engine", ...
Evaluate the code needed to compute a given Data object.
[ "Evaluate", "the", "code", "needed", "to", "compute", "a", "given", "Data", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/workflow/__init__.py#L85-L156
genialis/resolwe
resolwe/flow/executors/manager_commands.py
init
async def init(): """Create a connection to the Redis server.""" global redis_conn # pylint: disable=global-statement,invalid-name conn = await aioredis.create_connection( 'redis://{}:{}'.format( SETTINGS.get('FLOW_EXECUTOR', {}).get('REDIS_CONNECTION', {}).get('host', 'localhost'), ...
python
async def init(): """Create a connection to the Redis server.""" global redis_conn # pylint: disable=global-statement,invalid-name conn = await aioredis.create_connection( 'redis://{}:{}'.format( SETTINGS.get('FLOW_EXECUTOR', {}).get('REDIS_CONNECTION', {}).get('host', 'localhost'), ...
[ "async", "def", "init", "(", ")", ":", "global", "redis_conn", "# pylint: disable=global-statement,invalid-name", "conn", "=", "await", "aioredis", ".", "create_connection", "(", "'redis://{}:{}'", ".", "format", "(", "SETTINGS", ".", "get", "(", "'FLOW_EXECUTOR'", ...
Create a connection to the Redis server.
[ "Create", "a", "connection", "to", "the", "Redis", "server", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/manager_commands.py#L25-L35
genialis/resolwe
resolwe/flow/executors/manager_commands.py
send_manager_command
async def send_manager_command(cmd, expect_reply=True, extra_fields={}): """Send a properly formatted command to the manager. :param cmd: The command to send (:class:`str`). :param expect_reply: If ``True``, wait for the manager to reply with an acknowledgement packet. :param extra_fields: A di...
python
async def send_manager_command(cmd, expect_reply=True, extra_fields={}): """Send a properly formatted command to the manager. :param cmd: The command to send (:class:`str`). :param expect_reply: If ``True``, wait for the manager to reply with an acknowledgement packet. :param extra_fields: A di...
[ "async", "def", "send_manager_command", "(", "cmd", ",", "expect_reply", "=", "True", ",", "extra_fields", "=", "{", "}", ")", ":", "packet", "=", "{", "ExecutorProtocol", ".", "DATA_ID", ":", "DATA", "[", "'id'", "]", ",", "ExecutorProtocol", ".", "COMMAN...
Send a properly formatted command to the manager. :param cmd: The command to send (:class:`str`). :param expect_reply: If ``True``, wait for the manager to reply with an acknowledgement packet. :param extra_fields: A dictionary of extra information that's merged into the packet body (i.e. n...
[ "Send", "a", "properly", "formatted", "command", "to", "the", "manager", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/manager_commands.py#L44-L90
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
extract_values_query
def extract_values_query(query, field_list, out_stream=None): """Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). If...
python
def extract_values_query(query, field_list, out_stream=None): """Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). If...
[ "def", "extract_values_query", "(", "query", ",", "field_list", ",", "out_stream", "=", "None", ")", ":", "lookup_dict", ",", "generate_dict", "=", "_split_field_list", "(", "field_list", ")", "query", ",", "annotate_key_list", "=", "_annotate_query", "(", "query"...
Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). If None, return all fields. filter_arg_dict: dict ...
[ "Get", "list", "of", "dicts", "where", "each", "dict", "holds", "values", "from", "one", "SciObj", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L29-L66
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
extract_values
def extract_values(field_list=None, filter_arg_dict=None, out_stream=None): """Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). ...
python
def extract_values(field_list=None, filter_arg_dict=None, out_stream=None): """Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). ...
[ "def", "extract_values", "(", "field_list", "=", "None", ",", "filter_arg_dict", "=", "None", ",", "out_stream", "=", "None", ")", ":", "lookup_dict", ",", "generate_dict", "=", "_split_field_list", "(", "field_list", ")", "query", ",", "annotate_key_list", "=",...
Get list of dicts where each dict holds values from one SciObj. Args: field_list: list of str List of field names for which to return values. Must be strings from FIELD_NAME_TO_generate_dict.keys(). If None, return all fields. filter_arg_dict: dict ...
[ "Get", "list", "of", "dicts", "where", "each", "dict", "holds", "values", "from", "one", "SciObj", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L69-L99
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
assert_invalid_field_list
def assert_invalid_field_list(field_list): """raise d1_common.types.exceptions.InvalidRequest() if ``field_list`` contains any invalid field names. A list of the invalid fields is included in the exception. - Implicitly called by ``extract_values()``. """ if field_list is not None: invalid...
python
def assert_invalid_field_list(field_list): """raise d1_common.types.exceptions.InvalidRequest() if ``field_list`` contains any invalid field names. A list of the invalid fields is included in the exception. - Implicitly called by ``extract_values()``. """ if field_list is not None: invalid...
[ "def", "assert_invalid_field_list", "(", "field_list", ")", ":", "if", "field_list", "is", "not", "None", ":", "invalid_field_list", "=", "[", "v", "for", "v", "in", "field_list", "if", "v", "not", "in", "get_valid_field_name_list", "(", ")", "]", "if", "inv...
raise d1_common.types.exceptions.InvalidRequest() if ``field_list`` contains any invalid field names. A list of the invalid fields is included in the exception. - Implicitly called by ``extract_values()``.
[ "raise", "d1_common", ".", "types", ".", "exceptions", ".", "InvalidRequest", "()", "if", "field_list", "contains", "any", "invalid", "field", "names", ".", "A", "list", "of", "the", "invalid", "fields", "is", "included", "in", "the", "exception", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L130-L144
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
_annotate_query
def _annotate_query(query, generate_dict): """Add annotations to the query to retrieve values required by field value generate functions.""" annotate_key_list = [] for field_name, annotate_dict in generate_dict.items(): for annotate_name, annotate_func in annotate_dict["annotate_dict"].items(): ...
python
def _annotate_query(query, generate_dict): """Add annotations to the query to retrieve values required by field value generate functions.""" annotate_key_list = [] for field_name, annotate_dict in generate_dict.items(): for annotate_name, annotate_func in annotate_dict["annotate_dict"].items(): ...
[ "def", "_annotate_query", "(", "query", ",", "generate_dict", ")", ":", "annotate_key_list", "=", "[", "]", "for", "field_name", ",", "annotate_dict", "in", "generate_dict", ".", "items", "(", ")", ":", "for", "annotate_name", ",", "annotate_func", "in", "anno...
Add annotations to the query to retrieve values required by field value generate functions.
[ "Add", "annotations", "to", "the", "query", "to", "retrieve", "values", "required", "by", "field", "value", "generate", "functions", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L163-L171
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
_value_list_to_sciobj_dict
def _value_list_to_sciobj_dict( sciobj_value_list, lookup_list, lookup_dict, generate_dict ): """Create a dict where the keys are the requested field names, from the values returned by Django.""" sciobj_dict = {} # for sciobj_value, lookup_str in zip(sciobj_value_list, lookup_list): lookup_to_...
python
def _value_list_to_sciobj_dict( sciobj_value_list, lookup_list, lookup_dict, generate_dict ): """Create a dict where the keys are the requested field names, from the values returned by Django.""" sciobj_dict = {} # for sciobj_value, lookup_str in zip(sciobj_value_list, lookup_list): lookup_to_...
[ "def", "_value_list_to_sciobj_dict", "(", "sciobj_value_list", ",", "lookup_list", ",", "lookup_dict", ",", "generate_dict", ")", ":", "sciobj_dict", "=", "{", "}", "# for sciobj_value, lookup_str in zip(sciobj_value_list, lookup_list):", "lookup_to_value_dict", "=", "{", "k"...
Create a dict where the keys are the requested field names, from the values returned by Django.
[ "Create", "a", "dict", "where", "the", "keys", "are", "the", "requested", "field", "names", "from", "the", "values", "returned", "by", "Django", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L174-L193
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta_extract.py
_split_field_list
def _split_field_list(field_list): """Split the list of fields for which to extract values into lists by extraction methods. - Remove any duplicated field names. - Raises ValueError with list of any invalid field names in ``field_list``. """ lookup_dict = {} generate_dict = {} for fie...
python
def _split_field_list(field_list): """Split the list of fields for which to extract values into lists by extraction methods. - Remove any duplicated field names. - Raises ValueError with list of any invalid field names in ``field_list``. """ lookup_dict = {} generate_dict = {} for fie...
[ "def", "_split_field_list", "(", "field_list", ")", ":", "lookup_dict", "=", "{", "}", "generate_dict", "=", "{", "}", "for", "field_name", "in", "field_list", "or", "FIELD_NAME_TO_EXTRACT_DICT", ".", "keys", "(", ")", ":", "try", ":", "extract_dict", "=", "...
Split the list of fields for which to extract values into lists by extraction methods. - Remove any duplicated field names. - Raises ValueError with list of any invalid field names in ``field_list``.
[ "Split", "the", "list", "of", "fields", "for", "which", "to", "extract", "values", "into", "lists", "by", "extraction", "methods", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta_extract.py#L196-L218
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/util.py
dataoneTypes
def dataoneTypes(request): """Return the PyXB binding to use when handling a request.""" if is_v1_api(request): return d1_common.types.dataoneTypes_v1_1 elif is_v2_api(request) or is_diag_api(request): return d1_common.types.dataoneTypes_v2_0 else: raise d1_common.types.exception...
python
def dataoneTypes(request): """Return the PyXB binding to use when handling a request.""" if is_v1_api(request): return d1_common.types.dataoneTypes_v1_1 elif is_v2_api(request) or is_diag_api(request): return d1_common.types.dataoneTypes_v2_0 else: raise d1_common.types.exception...
[ "def", "dataoneTypes", "(", "request", ")", ":", "if", "is_v1_api", "(", "request", ")", ":", "return", "d1_common", ".", "types", ".", "dataoneTypes_v1_1", "elif", "is_v2_api", "(", "request", ")", "or", "is_diag_api", "(", "request", ")", ":", "return", ...
Return the PyXB binding to use when handling a request.
[ "Return", "the", "PyXB", "binding", "to", "use", "when", "handling", "a", "request", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/util.py#L46-L55
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/util.py
parse_and_normalize_url_date
def parse_and_normalize_url_date(date_str): """Parse a ISO 8601 date-time with optional timezone. - Return as datetime with timezone adjusted to UTC. - Return naive date-time set to UTC. """ if date_str is None: return None try: return d1_common.date_time.dt_from_iso8601_str(da...
python
def parse_and_normalize_url_date(date_str): """Parse a ISO 8601 date-time with optional timezone. - Return as datetime with timezone adjusted to UTC. - Return naive date-time set to UTC. """ if date_str is None: return None try: return d1_common.date_time.dt_from_iso8601_str(da...
[ "def", "parse_and_normalize_url_date", "(", "date_str", ")", ":", "if", "date_str", "is", "None", ":", "return", "None", "try", ":", "return", "d1_common", ".", "date_time", ".", "dt_from_iso8601_str", "(", "date_str", ")", "except", "d1_common", ".", "date_time...
Parse a ISO 8601 date-time with optional timezone. - Return as datetime with timezone adjusted to UTC. - Return naive date-time set to UTC.
[ "Parse", "a", "ISO", "8601", "date", "-", "time", "with", "optional", "timezone", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/util.py#L179-L196
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.get
def get(self, doc_id): """Retrieve the specified document.""" resp_dict = self._get_query(q='id:{}'.format(doc_id)) if resp_dict['response']['numFound'] > 0: return resp_dict['response']['docs'][0]
python
def get(self, doc_id): """Retrieve the specified document.""" resp_dict = self._get_query(q='id:{}'.format(doc_id)) if resp_dict['response']['numFound'] > 0: return resp_dict['response']['docs'][0]
[ "def", "get", "(", "self", ",", "doc_id", ")", ":", "resp_dict", "=", "self", ".", "_get_query", "(", "q", "=", "'id:{}'", ".", "format", "(", "doc_id", ")", ")", "if", "resp_dict", "[", "'response'", "]", "[", "'numFound'", "]", ">", "0", ":", "re...
Retrieve the specified document.
[ "Retrieve", "the", "specified", "document", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L178-L182
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.get_ids
def get_ids(self, start=0, rows=1000, **query_dict): """Retrieve a list of identifiers for documents matching the query.""" resp_dict = self._get_query(start=start, rows=rows, **query_dict) return { 'matches': resp_dict['response']['numFound'], 'start': start, ...
python
def get_ids(self, start=0, rows=1000, **query_dict): """Retrieve a list of identifiers for documents matching the query.""" resp_dict = self._get_query(start=start, rows=rows, **query_dict) return { 'matches': resp_dict['response']['numFound'], 'start': start, ...
[ "def", "get_ids", "(", "self", ",", "start", "=", "0", ",", "rows", "=", "1000", ",", "*", "*", "query_dict", ")", ":", "resp_dict", "=", "self", ".", "_get_query", "(", "start", "=", "start", ",", "rows", "=", "rows", ",", "*", "*", "query_dict", ...
Retrieve a list of identifiers for documents matching the query.
[ "Retrieve", "a", "list", "of", "identifiers", "for", "documents", "matching", "the", "query", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L185-L192
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.count
def count(self, **query_dict): """Return the number of entries that match query.""" param_dict = query_dict.copy() param_dict['count'] = 0 resp_dict = self._get_query(**param_dict) return resp_dict['response']['numFound']
python
def count(self, **query_dict): """Return the number of entries that match query.""" param_dict = query_dict.copy() param_dict['count'] = 0 resp_dict = self._get_query(**param_dict) return resp_dict['response']['numFound']
[ "def", "count", "(", "self", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "param_dict", "[", "'count'", "]", "=", "0", "resp_dict", "=", "self", ".", "_get_query", "(", "*", "*", "param_dict", ")", "r...
Return the number of entries that match query.
[ "Return", "the", "number", "of", "entries", "that", "match", "query", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L194-L199
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.get_field_values
def get_field_values(self, name, maxvalues=-1, sort=True, **query_dict): """Retrieve the unique values for a field, along with their usage counts. :param name: Name of field for which to retrieve values :type name: string :param sort: Sort the result :param maxvalues: Maximum ...
python
def get_field_values(self, name, maxvalues=-1, sort=True, **query_dict): """Retrieve the unique values for a field, along with their usage counts. :param name: Name of field for which to retrieve values :type name: string :param sort: Sort the result :param maxvalues: Maximum ...
[ "def", "get_field_values", "(", "self", ",", "name", ",", "maxvalues", "=", "-", "1", ",", "sort", "=", "True", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "param_dict", ".", "update", "(", "{", "'ro...
Retrieve the unique values for a field, along with their usage counts. :param name: Name of field for which to retrieve values :type name: string :param sort: Sort the result :param maxvalues: Maximum number of values to retrieve. Default is -1, which causes retrieval of all...
[ "Retrieve", "the", "unique", "values", "for", "a", "field", "along", "with", "their", "usage", "counts", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L201-L230
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.get_field_min_max
def get_field_min_max(self, name, **query_dict): """Returns the minimum and maximum values of the specified field. This requires two search calls to the service, each requesting a single value of a single field. @param name(string) Name of the field @param q(string) Query identi...
python
def get_field_min_max(self, name, **query_dict): """Returns the minimum and maximum values of the specified field. This requires two search calls to the service, each requesting a single value of a single field. @param name(string) Name of the field @param q(string) Query identi...
[ "def", "get_field_min_max", "(", "self", ",", "name", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "param_dict", ".", "update", "(", "{", "'rows'", ":", "1", ",", "'fl'", ":", "name", ",", "'sort'", "...
Returns the minimum and maximum values of the specified field. This requires two search calls to the service, each requesting a single value of a single field. @param name(string) Name of the field @param q(string) Query identifying range of records for min and max values @param...
[ "Returns", "the", "minimum", "and", "maximum", "values", "of", "the", "specified", "field", ".", "This", "requires", "two", "search", "calls", "to", "the", "service", "each", "requesting", "a", "single", "value", "of", "a", "single", "field", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L232-L256
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.field_alpha_histogram
def field_alpha_histogram( self, name, n_bins=10, include_queries=True, **query_dict ): """Generates a histogram of values from a string field. Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal division of the fields. """ bin_list = [] ...
python
def field_alpha_histogram( self, name, n_bins=10, include_queries=True, **query_dict ): """Generates a histogram of values from a string field. Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal division of the fields. """ bin_list = [] ...
[ "def", "field_alpha_histogram", "(", "self", ",", "name", ",", "n_bins", "=", "10", ",", "include_queries", "=", "True", ",", "*", "*", "query_dict", ")", ":", "bin_list", "=", "[", "]", "q_bin", "=", "[", "]", "try", ":", "# get total number of values for...
Generates a histogram of values from a string field. Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal division of the fields.
[ "Generates", "a", "histogram", "of", "values", "from", "a", "string", "field", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L258-L362
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient.add_docs
def add_docs(self, docs): """docs is a list of fields that are a dictionary of name:value for a record.""" return self.query( 'solr', '<add>{}</add>'.format( ''.join([self._format_add(fields) for fields in docs]) ), do_post=True, )
python
def add_docs(self, docs): """docs is a list of fields that are a dictionary of name:value for a record.""" return self.query( 'solr', '<add>{}</add>'.format( ''.join([self._format_add(fields) for fields in docs]) ), do_post=True, )
[ "def", "add_docs", "(", "self", ",", "docs", ")", ":", "return", "self", ".", "query", "(", "'solr'", ",", "'<add>{}</add>'", ".", "format", "(", "''", ".", "join", "(", "[", "self", ".", "_format_add", "(", "fields", ")", "for", "fields", "in", "doc...
docs is a list of fields that are a dictionary of name:value for a record.
[ "docs", "is", "a", "list", "of", "fields", "that", "are", "a", "dictionary", "of", "name", ":", "value", "for", "a", "record", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L385-L393
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._coerce_type
def _coerce_type(self, field_type, value): """Returns unicode(value) after trying to coerce it into the Solr field type. @param field_type(string) The Solr field type for the value @param value(any) The value that is to be represented as Unicode text. """ if value is None: ...
python
def _coerce_type(self, field_type, value): """Returns unicode(value) after trying to coerce it into the Solr field type. @param field_type(string) The Solr field type for the value @param value(any) The value that is to be represented as Unicode text. """ if value is None: ...
[ "def", "_coerce_type", "(", "self", ",", "field_type", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "field_type", "==", "'string'", ":", "return", "str", "(", "value", ")", "elif", "field_type", "==", "'text'", ":", ...
Returns unicode(value) after trying to coerce it into the Solr field type. @param field_type(string) The Solr field type for the value @param value(any) The value that is to be represented as Unicode text.
[ "Returns", "unicode", "(", "value", ")", "after", "trying", "to", "coerce", "it", "into", "the", "Solr", "field", "type", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L412-L451
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._get_solr_type
def _get_solr_type(self, field): """Returns the Solr type of the specified field name. Assumes the convention of dynamic fields using an underscore + type character code for the field name. """ field_type = 'string' try: field_type = FIELD_TYPE_CONVERSION_MA...
python
def _get_solr_type(self, field): """Returns the Solr type of the specified field name. Assumes the convention of dynamic fields using an underscore + type character code for the field name. """ field_type = 'string' try: field_type = FIELD_TYPE_CONVERSION_MA...
[ "def", "_get_solr_type", "(", "self", ",", "field", ")", ":", "field_type", "=", "'string'", "try", ":", "field_type", "=", "FIELD_TYPE_CONVERSION_MAP", "[", "field", "]", "return", "field_type", "except", ":", "pass", "fta", "=", "field", ".", "split", "(",...
Returns the Solr type of the specified field name. Assumes the convention of dynamic fields using an underscore + type character code for the field name.
[ "Returns", "the", "Solr", "type", "of", "the", "specified", "field", "name", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L453-L475
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._get_query
def _get_query(self, **query_dict): """Perform a GET query against Solr and return the response as a Python dict.""" param_dict = query_dict.copy() return self._send_query(do_post=False, **param_dict)
python
def _get_query(self, **query_dict): """Perform a GET query against Solr and return the response as a Python dict.""" param_dict = query_dict.copy() return self._send_query(do_post=False, **param_dict)
[ "def", "_get_query", "(", "self", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "return", "self", ".", "_send_query", "(", "do_post", "=", "False", ",", "*", "*", "param_dict", ")" ]
Perform a GET query against Solr and return the response as a Python dict.
[ "Perform", "a", "GET", "query", "against", "Solr", "and", "return", "the", "response", "as", "a", "Python", "dict", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L501-L504
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._post_query
def _post_query(self, **query_dict): """Perform a POST query against Solr and return the response as a Python dict.""" param_dict = query_dict.copy() return self._send_query(do_post=True, **param_dict)
python
def _post_query(self, **query_dict): """Perform a POST query against Solr and return the response as a Python dict.""" param_dict = query_dict.copy() return self._send_query(do_post=True, **param_dict)
[ "def", "_post_query", "(", "self", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "return", "self", ".", "_send_query", "(", "do_post", "=", "True", ",", "*", "*", "param_dict", ")" ]
Perform a POST query against Solr and return the response as a Python dict.
[ "Perform", "a", "POST", "query", "against", "Solr", "and", "return", "the", "response", "as", "a", "Python", "dict", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L506-L510
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._send_query
def _send_query(self, do_post=False, **query_dict): """Perform a query against Solr and return the response as a Python dict.""" # self._prepare_query_term() param_dict = query_dict.copy() param_dict.setdefault('wt', 'json') param_dict.setdefault('q', '*.*') param_dict.se...
python
def _send_query(self, do_post=False, **query_dict): """Perform a query against Solr and return the response as a Python dict.""" # self._prepare_query_term() param_dict = query_dict.copy() param_dict.setdefault('wt', 'json') param_dict.setdefault('q', '*.*') param_dict.se...
[ "def", "_send_query", "(", "self", ",", "do_post", "=", "False", ",", "*", "*", "query_dict", ")", ":", "# self._prepare_query_term()", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "param_dict", ".", "setdefault", "(", "'wt'", ",", "'json'", ")", ...
Perform a query against Solr and return the response as a Python dict.
[ "Perform", "a", "query", "against", "Solr", "and", "return", "the", "response", "as", "a", "Python", "dict", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L512-L519
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._prepare_query_term
def _prepare_query_term(self, field, term): """Prepare a query term for inclusion in a query. This escapes the term and if necessary, wraps the term in quotes. """ if term == "*": return term add_star = False if term[len(term) - 1] == '*': add_st...
python
def _prepare_query_term(self, field, term): """Prepare a query term for inclusion in a query. This escapes the term and if necessary, wraps the term in quotes. """ if term == "*": return term add_star = False if term[len(term) - 1] == '*': add_st...
[ "def", "_prepare_query_term", "(", "self", ",", "field", ",", "term", ")", ":", "if", "term", "==", "\"*\"", ":", "return", "term", "add_star", "=", "False", "if", "term", "[", "len", "(", "term", ")", "-", "1", "]", "==", "'*'", ":", "add_star", "...
Prepare a query term for inclusion in a query. This escapes the term and if necessary, wraps the term in quotes.
[ "Prepare", "a", "query", "term", "for", "inclusion", "in", "a", "query", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L523-L540
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrClient._escape_query_term
def _escape_query_term(self, term): """Escape a query term for inclusion in a query. - Also see: prepare_query_term(). """ term = term.replace('\\', '\\\\') for c in RESERVED_CHAR_LIST: term = term.replace(c, r'\{}'.format(c)) return term
python
def _escape_query_term(self, term): """Escape a query term for inclusion in a query. - Also see: prepare_query_term(). """ term = term.replace('\\', '\\\\') for c in RESERVED_CHAR_LIST: term = term.replace(c, r'\{}'.format(c)) return term
[ "def", "_escape_query_term", "(", "self", ",", "term", ")", ":", "term", "=", "term", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", "for", "c", "in", "RESERVED_CHAR_LIST", ":", "term", "=", "term", ".", "replace", "(", "c", ",", "r'\\{}'", "."...
Escape a query term for inclusion in a query. - Also see: prepare_query_term().
[ "Escape", "a", "query", "term", "for", "inclusion", "in", "a", "query", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L542-L551
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrSearchResponseIterator._next_page
def _next_page(self, offset): """Retrieves the next set of results from the service.""" self._log.debug("Iterator c_record={}".format(self.c_record)) page_size = self.page_size if (offset + page_size) > self.max_records: page_size = self.max_records - offset param_dic...
python
def _next_page(self, offset): """Retrieves the next set of results from the service.""" self._log.debug("Iterator c_record={}".format(self.c_record)) page_size = self.page_size if (offset + page_size) > self.max_records: page_size = self.max_records - offset param_dic...
[ "def", "_next_page", "(", "self", ",", "offset", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"Iterator c_record={}\"", ".", "format", "(", "self", ".", "c_record", ")", ")", "page_size", "=", "self", ".", "page_size", "if", "(", "offset", "+", ...
Retrieves the next set of results from the service.
[ "Retrieves", "the", "next", "set", "of", "results", "from", "the", "service", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L627-L643
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
SolrValuesResponseIterator._next_page
def _next_page(self, offset): """Retrieves the next set of results from the service.""" self._log.debug("Iterator c_record={}".format(self.c_record)) param_dict = self.query_dict.copy() param_dict.update( { 'rows': '0', 'facet': 'true', ...
python
def _next_page(self, offset): """Retrieves the next set of results from the service.""" self._log.debug("Iterator c_record={}".format(self.c_record)) param_dict = self.query_dict.copy() param_dict.update( { 'rows': '0', 'facet': 'true', ...
[ "def", "_next_page", "(", "self", ",", "offset", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"Iterator c_record={}\"", ".", "format", "(", "self", ".", "c_record", ")", ")", "param_dict", "=", "self", ".", "query_dict", ".", "copy", "(", ")", "...
Retrieves the next set of results from the service.
[ "Retrieves", "the", "next", "set", "of", "results", "from", "the", "service", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L795-L818
genialis/resolwe
resolwe/flow/migrations/0023_process_entity_2.py
migrate_flow_collection
def migrate_flow_collection(apps, schema_editor): """Migrate 'flow_collection' field to 'entity_type'.""" Process = apps.get_model('flow', 'Process') DescriptorSchema = apps.get_model('flow', 'DescriptorSchema') for process in Process.objects.all(): process.entity_type = process.flow_collection...
python
def migrate_flow_collection(apps, schema_editor): """Migrate 'flow_collection' field to 'entity_type'.""" Process = apps.get_model('flow', 'Process') DescriptorSchema = apps.get_model('flow', 'DescriptorSchema') for process in Process.objects.all(): process.entity_type = process.flow_collection...
[ "def", "migrate_flow_collection", "(", "apps", ",", "schema_editor", ")", ":", "Process", "=", "apps", ".", "get_model", "(", "'flow'", ",", "'Process'", ")", "DescriptorSchema", "=", "apps", ".", "get_model", "(", "'flow'", ",", "'DescriptorSchema'", ")", "fo...
Migrate 'flow_collection' field to 'entity_type'.
[ "Migrate", "flow_collection", "field", "to", "entity_type", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0023_process_entity_2.py#L8-L24
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
get_pyxb_binding_by_api_version
def get_pyxb_binding_by_api_version(api_major, api_minor=0): """Map DataONE API version tag to PyXB binding. Given a DataONE API major version number, return PyXB binding that can serialize and deserialize DataONE XML docs of that version. Args: api_major, api_minor: str or int DataONE A...
python
def get_pyxb_binding_by_api_version(api_major, api_minor=0): """Map DataONE API version tag to PyXB binding. Given a DataONE API major version number, return PyXB binding that can serialize and deserialize DataONE XML docs of that version. Args: api_major, api_minor: str or int DataONE A...
[ "def", "get_pyxb_binding_by_api_version", "(", "api_major", ",", "api_minor", "=", "0", ")", ":", "try", ":", "return", "VERSION_TO_BINDING_DICT", "[", "api_major", ",", "api_minor", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'Unknown DataONE API v...
Map DataONE API version tag to PyXB binding. Given a DataONE API major version number, return PyXB binding that can serialize and deserialize DataONE XML docs of that version. Args: api_major, api_minor: str or int DataONE API major and minor version numbers. - If ``api_major`` is a...
[ "Map", "DataONE", "API", "version", "tag", "to", "PyXB", "binding", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L119-L145
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
extract_version_tag_from_url
def extract_version_tag_from_url(url): """Extract a DataONE API version tag from a MN or CN service endpoint URL. Args: url : str Service endpoint URL. E.g.: ``https://mn.example.org/path/v2/object/pid``. Returns: str : Valid version tags are currently ``v1`` or ``v2``. """ m ...
python
def extract_version_tag_from_url(url): """Extract a DataONE API version tag from a MN or CN service endpoint URL. Args: url : str Service endpoint URL. E.g.: ``https://mn.example.org/path/v2/object/pid``. Returns: str : Valid version tags are currently ``v1`` or ``v2``. """ m ...
[ "def", "extract_version_tag_from_url", "(", "url", ")", ":", "m", "=", "re", ".", "match", "(", "r'(/|^)(v\\d)(/|$)'", ",", "url", ")", "if", "not", "m", ":", "return", "None", "return", "m", ".", "group", "(", "2", ")" ]
Extract a DataONE API version tag from a MN or CN service endpoint URL. Args: url : str Service endpoint URL. E.g.: ``https://mn.example.org/path/v2/object/pid``. Returns: str : Valid version tags are currently ``v1`` or ``v2``.
[ "Extract", "a", "DataONE", "API", "version", "tag", "from", "a", "MN", "or", "CN", "service", "endpoint", "URL", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L159-L173
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
str_to_v1_str
def str_to_v1_str(xml_str): """Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API ...
python
def str_to_v1_str(xml_str): """Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API ...
[ "def", "str_to_v1_str", "(", "xml_str", ")", ":", "if", "str_is_v1", "(", "xml_str", ")", ":", "return", "xml_str", "etree_obj", "=", "str_to_etree", "(", "xml_str", ")", "strip_v2_elements", "(", "etree_obj", ")", "etree_replace_namespace", "(", "etree_obj", ",...
Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API v1 XML doc. E.g.: ``SystemMetadata ...
[ "Convert", "a", "API", "v2", "XML", "doc", "to", "v1", "XML", "doc", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L190-L210
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
str_to_v2_str
def str_to_v2_str(xml_str): """Convert a API v1 XML doc to v2 XML doc. All v1 elements are valid for v2, so only changes namespace. Args: xml_str : str API v1 XML doc. E.g.: ``SystemMetadata v1``. Returns: str : API v2 XML doc. E.g.: ``SystemMetadata v2``. """ if str_is_v...
python
def str_to_v2_str(xml_str): """Convert a API v1 XML doc to v2 XML doc. All v1 elements are valid for v2, so only changes namespace. Args: xml_str : str API v1 XML doc. E.g.: ``SystemMetadata v1``. Returns: str : API v2 XML doc. E.g.: ``SystemMetadata v2``. """ if str_is_v...
[ "def", "str_to_v2_str", "(", "xml_str", ")", ":", "if", "str_is_v2", "(", "xml_str", ")", ":", "return", "xml_str", "etree_obj", "=", "str_to_etree", "(", "xml_str", ")", "etree_replace_namespace", "(", "etree_obj", ",", "d1_common", ".", "types", ".", "dataon...
Convert a API v1 XML doc to v2 XML doc. All v1 elements are valid for v2, so only changes namespace. Args: xml_str : str API v1 XML doc. E.g.: ``SystemMetadata v1``. Returns: str : API v2 XML doc. E.g.: ``SystemMetadata v2``.
[ "Convert", "a", "API", "v1", "XML", "doc", "to", "v2", "XML", "doc", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L250-L267
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
str_is_well_formed
def str_is_well_formed(xml_str): """ Args: xml_str : str DataONE API XML doc. Returns: bool: **True** if XML doc is well formed. """ try: str_to_etree(xml_str) except xml.etree.ElementTree.ParseError: return False else: return True
python
def str_is_well_formed(xml_str): """ Args: xml_str : str DataONE API XML doc. Returns: bool: **True** if XML doc is well formed. """ try: str_to_etree(xml_str) except xml.etree.ElementTree.ParseError: return False else: return True
[ "def", "str_is_well_formed", "(", "xml_str", ")", ":", "try", ":", "str_to_etree", "(", "xml_str", ")", "except", "xml", ".", "etree", ".", "ElementTree", ".", "ParseError", ":", "return", "False", "else", ":", "return", "True" ]
Args: xml_str : str DataONE API XML doc. Returns: bool: **True** if XML doc is well formed.
[ "Args", ":", "xml_str", ":", "str", "DataONE", "API", "XML", "doc", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L437-L451
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
pyxb_is_v1
def pyxb_is_v1(pyxb_obj): """ Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v1 type. """ # TODO: Will not detect v1.2 as v1. return ( pyxb_obj._element().name().namespace() == d1_common.types.dataon...
python
def pyxb_is_v1(pyxb_obj): """ Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v1 type. """ # TODO: Will not detect v1.2 as v1. return ( pyxb_obj._element().name().namespace() == d1_common.types.dataon...
[ "def", "pyxb_is_v1", "(", "pyxb_obj", ")", ":", "# TODO: Will not detect v1.2 as v1.", "return", "(", "pyxb_obj", ".", "_element", "(", ")", ".", "name", "(", ")", ".", "namespace", "(", ")", "==", "d1_common", ".", "types", ".", "dataoneTypes_v1", ".", "Nam...
Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v1 type.
[ "Args", ":", "pyxb_obj", ":", "PyXB", "object", "PyXB", "object", "holding", "an", "unknown", "type", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L455-L468
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
pyxb_is_v2
def pyxb_is_v2(pyxb_obj): """ Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v2 type. """ return ( pyxb_obj._element().name().namespace() == d1_common.types.dataoneTypes_v2_0.Namespace )
python
def pyxb_is_v2(pyxb_obj): """ Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v2 type. """ return ( pyxb_obj._element().name().namespace() == d1_common.types.dataoneTypes_v2_0.Namespace )
[ "def", "pyxb_is_v2", "(", "pyxb_obj", ")", ":", "return", "(", "pyxb_obj", ".", "_element", "(", ")", ".", "name", "(", ")", ".", "namespace", "(", ")", "==", "d1_common", ".", "types", ".", "dataoneTypes_v2_0", ".", "Namespace", ")" ]
Args: pyxb_obj : PyXB object PyXB object holding an unknown type. Returns: bool: **True** if ``pyxb_obj`` holds an API v2 type.
[ "Args", ":", "pyxb_obj", ":", "PyXB", "object", "PyXB", "object", "holding", "an", "unknown", "type", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L472-L484
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
str_to_etree
def str_to_etree(xml_str, encoding='utf-8'): """Deserialize API XML doc to an ElementTree. Args: xml_str: bytes DataONE API XML doc encoding: str Decoder to use when converting the XML doc ``bytes`` to a Unicode str. Returns: ElementTree: Matching the API version of the ...
python
def str_to_etree(xml_str, encoding='utf-8'): """Deserialize API XML doc to an ElementTree. Args: xml_str: bytes DataONE API XML doc encoding: str Decoder to use when converting the XML doc ``bytes`` to a Unicode str. Returns: ElementTree: Matching the API version of the ...
[ "def", "str_to_etree", "(", "xml_str", ",", "encoding", "=", "'utf-8'", ")", ":", "parser", "=", "xml", ".", "etree", ".", "ElementTree", ".", "XMLParser", "(", "encoding", "=", "encoding", ")", "return", "xml", ".", "etree", ".", "ElementTree", ".", "fr...
Deserialize API XML doc to an ElementTree. Args: xml_str: bytes DataONE API XML doc encoding: str Decoder to use when converting the XML doc ``bytes`` to a Unicode str. Returns: ElementTree: Matching the API version of the XML doc.
[ "Deserialize", "API", "XML", "doc", "to", "an", "ElementTree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L506-L521
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
replace_namespace_with_prefix
def replace_namespace_with_prefix(tag_str, ns_reverse_dict=None): """Convert XML tag names with namespace on the form ``{namespace}tag`` to form ``prefix:tag``. Args: tag_str: str Tag name with namespace. E.g.: ``{http://www.openarchives.org/ore/terms/}ResourceMap``. ns_reverse...
python
def replace_namespace_with_prefix(tag_str, ns_reverse_dict=None): """Convert XML tag names with namespace on the form ``{namespace}tag`` to form ``prefix:tag``. Args: tag_str: str Tag name with namespace. E.g.: ``{http://www.openarchives.org/ore/terms/}ResourceMap``. ns_reverse...
[ "def", "replace_namespace_with_prefix", "(", "tag_str", ",", "ns_reverse_dict", "=", "None", ")", ":", "ns_reverse_dict", "=", "ns_reverse_dict", "or", "NS_REVERSE_DICT", "for", "namespace_str", ",", "prefix_str", "in", "ns_reverse_dict", ".", "items", "(", ")", ":"...
Convert XML tag names with namespace on the form ``{namespace}tag`` to form ``prefix:tag``. Args: tag_str: str Tag name with namespace. E.g.: ``{http://www.openarchives.org/ore/terms/}ResourceMap``. ns_reverse_dict : dict A dictionary of namespace to prefix to use for the c...
[ "Convert", "XML", "tag", "names", "with", "namespace", "on", "the", "form", "{", "namespace", "}", "tag", "to", "form", "prefix", ":", "tag", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L587-L609
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
etree_replace_namespace
def etree_replace_namespace(etree_obj, ns_str): """In-place change the namespace of elements in an ElementTree. Args: etree_obj: ElementTree ns_str : str The namespace to set. E.g.: ``http://ns.dataone.org/service/types/v1``. """ def _replace_recursive(el, n): el.tag = re...
python
def etree_replace_namespace(etree_obj, ns_str): """In-place change the namespace of elements in an ElementTree. Args: etree_obj: ElementTree ns_str : str The namespace to set. E.g.: ``http://ns.dataone.org/service/types/v1``. """ def _replace_recursive(el, n): el.tag = re...
[ "def", "etree_replace_namespace", "(", "etree_obj", ",", "ns_str", ")", ":", "def", "_replace_recursive", "(", "el", ",", "n", ")", ":", "el", ".", "tag", "=", "re", ".", "sub", "(", "r'{.*\\}'", ",", "'{{{}}}'", ".", "format", "(", "n", ")", ",", "e...
In-place change the namespace of elements in an ElementTree. Args: etree_obj: ElementTree ns_str : str The namespace to set. E.g.: ``http://ns.dataone.org/service/types/v1``.
[ "In", "-", "place", "change", "the", "namespace", "of", "elements", "in", "an", "ElementTree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L612-L630
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
strip_v2_elements
def strip_v2_elements(etree_obj): """In-place remove elements and attributes that are only valid in v2 types. Args: etree_obj: ElementTree ElementTree holding one of the DataONE API types that changed between v1 and v2. """ if etree_obj.tag == v2_0_tag('logEntry'): strip_logEntry(etr...
python
def strip_v2_elements(etree_obj): """In-place remove elements and attributes that are only valid in v2 types. Args: etree_obj: ElementTree ElementTree holding one of the DataONE API types that changed between v1 and v2. """ if etree_obj.tag == v2_0_tag('logEntry'): strip_logEntry(etr...
[ "def", "strip_v2_elements", "(", "etree_obj", ")", ":", "if", "etree_obj", ".", "tag", "==", "v2_0_tag", "(", "'logEntry'", ")", ":", "strip_logEntry", "(", "etree_obj", ")", "elif", "etree_obj", ".", "tag", "==", "v2_0_tag", "(", "'log'", ")", ":", "strip...
In-place remove elements and attributes that are only valid in v2 types. Args: etree_obj: ElementTree ElementTree holding one of the DataONE API types that changed between v1 and v2.
[ "In", "-", "place", "remove", "elements", "and", "attributes", "that", "are", "only", "valid", "in", "v2", "types", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L633-L651
DataONEorg/d1_python
lib_common/src/d1_common/type_conversions.py
strip_system_metadata
def strip_system_metadata(etree_obj): """In-place remove elements and attributes that are only valid in v2 types from v1 System Metadata. Args: etree_obj: ElementTree ElementTree holding a v1 SystemMetadata. """ for series_id_el in etree_obj.findall('seriesId'): etree_obj.remove(seri...
python
def strip_system_metadata(etree_obj): """In-place remove elements and attributes that are only valid in v2 types from v1 System Metadata. Args: etree_obj: ElementTree ElementTree holding a v1 SystemMetadata. """ for series_id_el in etree_obj.findall('seriesId'): etree_obj.remove(seri...
[ "def", "strip_system_metadata", "(", "etree_obj", ")", ":", "for", "series_id_el", "in", "etree_obj", ".", "findall", "(", "'seriesId'", ")", ":", "etree_obj", ".", "remove", "(", "series_id_el", ")", "for", "media_type_el", "in", "etree_obj", ".", "findall", ...
In-place remove elements and attributes that are only valid in v2 types from v1 System Metadata. Args: etree_obj: ElementTree ElementTree holding a v1 SystemMetadata.
[ "In", "-", "place", "remove", "elements", "and", "attributes", "that", "are", "only", "valid", "in", "v2", "types", "from", "v1", "System", "Metadata", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/type_conversions.py#L654-L666
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/process_replication_queue.py
ReplicationQueueProcessor._create_replica
def _create_replica(self, sysmeta_pyxb, sciobj_bytestream): """GMN handles replicas differently from native objects, with the main differences being related to handling of restrictions related to revision chains and SIDs. So this create sequence differs significantly from the regular on...
python
def _create_replica(self, sysmeta_pyxb, sciobj_bytestream): """GMN handles replicas differently from native objects, with the main differences being related to handling of restrictions related to revision chains and SIDs. So this create sequence differs significantly from the regular on...
[ "def", "_create_replica", "(", "self", ",", "sysmeta_pyxb", ",", "sciobj_bytestream", ")", ":", "pid", "=", "d1_common", ".", "xml", ".", "get_req_val", "(", "sysmeta_pyxb", ".", "identifier", ")", "self", ".", "_assert_is_pid_of_local_unprocessed_replica", "(", "...
GMN handles replicas differently from native objects, with the main differences being related to handling of restrictions related to revision chains and SIDs. So this create sequence differs significantly from the regular one that is accessed through MNStorage.create().
[ "GMN", "handles", "replicas", "differently", "from", "native", "objects", "with", "the", "main", "differences", "being", "related", "to", "handling", "of", "restrictions", "related", "to", "revision", "chains", "and", "SIDs", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/process_replication_queue.py#L228-L246
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.restricted_import
async def restricted_import(self, async_client, node_type): """Import only the Science Objects specified by a text file. The file must be UTF-8 encoded and contain one PIDs or SIDs per line. """ item_task_name = "Importing objects" pid_path = self.options['pid_path'] i...
python
async def restricted_import(self, async_client, node_type): """Import only the Science Objects specified by a text file. The file must be UTF-8 encoded and contain one PIDs or SIDs per line. """ item_task_name = "Importing objects" pid_path = self.options['pid_path'] i...
[ "async", "def", "restricted_import", "(", "self", ",", "async_client", ",", "node_type", ")", ":", "item_task_name", "=", "\"Importing objects\"", "pid_path", "=", "self", ".", "options", "[", "'pid_path'", "]", "if", "not", "os", ".", "path", ".", "exists", ...
Import only the Science Objects specified by a text file. The file must be UTF-8 encoded and contain one PIDs or SIDs per line.
[ "Import", "only", "the", "Science", "Objects", "specified", "by", "a", "text", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L261-L289
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.import_aggregated
async def import_aggregated(self, async_client, pid): """Import the SciObj at {pid}. If the SciObj is a Resource Map, also recursively import the aggregated objects. """ self._logger.info('Importing: {}'.format(pid)) task_set = set() object_info_pyxb = d1_common.types...
python
async def import_aggregated(self, async_client, pid): """Import the SciObj at {pid}. If the SciObj is a Resource Map, also recursively import the aggregated objects. """ self._logger.info('Importing: {}'.format(pid)) task_set = set() object_info_pyxb = d1_common.types...
[ "async", "def", "import_aggregated", "(", "self", ",", "async_client", ",", "pid", ")", ":", "self", ".", "_logger", ".", "info", "(", "'Importing: {}'", ".", "format", "(", "pid", ")", ")", "task_set", "=", "set", "(", ")", "object_info_pyxb", "=", "d1_...
Import the SciObj at {pid}. If the SciObj is a Resource Map, also recursively import the aggregated objects.
[ "Import", "the", "SciObj", "at", "{", "pid", "}", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L291-L324
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.get_object_proxy_location
async def get_object_proxy_location(self, client, pid): """If object is proxied, return the proxy location URL. If object is local, return None. """ try: return (await client.describe(pid)).get("DataONE-Proxy") except d1_common.types.exceptions.DataONEException: ...
python
async def get_object_proxy_location(self, client, pid): """If object is proxied, return the proxy location URL. If object is local, return None. """ try: return (await client.describe(pid)).get("DataONE-Proxy") except d1_common.types.exceptions.DataONEException: ...
[ "async", "def", "get_object_proxy_location", "(", "self", ",", "client", ",", "pid", ")", ":", "try", ":", "return", "(", "await", "client", ".", "describe", "(", "pid", ")", ")", ".", "get", "(", "\"DataONE-Proxy\"", ")", "except", "d1_common", ".", "ty...
If object is proxied, return the proxy location URL. If object is local, return None.
[ "If", "object", "is", "proxied", "return", "the", "proxy", "location", "URL", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L447-L457
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.get_list_objects_arg_dict
def get_list_objects_arg_dict(self, node_type): """Create a dict of arguments that will be passed to listObjects(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects(). """ arg_dict = { ...
python
def get_list_objects_arg_dict(self, node_type): """Create a dict of arguments that will be passed to listObjects(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects(). """ arg_dict = { ...
[ "def", "get_list_objects_arg_dict", "(", "self", ",", "node_type", ")", ":", "arg_dict", "=", "{", "# Restrict query for faster debugging", "# \"fromDate\": datetime.datetime(2017, 1, 1),", "# \"toDate\": datetime.datetime(2017, 1, 10),", "}", "if", "node_type", "==", "\"cn\"", ...
Create a dict of arguments that will be passed to listObjects(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects().
[ "Create", "a", "dict", "of", "arguments", "that", "will", "be", "passed", "to", "listObjects", "()", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L477-L491
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.get_log_records_arg_dict
def get_log_records_arg_dict(self, node_type): """Create a dict of arguments that will be passed to getLogRecords(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects(). """ arg_dict = { ...
python
def get_log_records_arg_dict(self, node_type): """Create a dict of arguments that will be passed to getLogRecords(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects(). """ arg_dict = { ...
[ "def", "get_log_records_arg_dict", "(", "self", ",", "node_type", ")", ":", "arg_dict", "=", "{", "# Restrict query for faster debugging", "# \"fromDate\": datetime.datetime(2017, 1, 1),", "# \"toDate\": datetime.datetime(2017, 1, 3),", "}", "if", "node_type", "==", "\"cn\"", "...
Create a dict of arguments that will be passed to getLogRecords(). If {node_type} is a CN, add filtering to include only objects from this GMN instance in the ObjectList returned by CNCore.listObjects().
[ "Create", "a", "dict", "of", "arguments", "that", "will", "be", "passed", "to", "getLogRecords", "()", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L517-L531
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.is_cn
async def is_cn(self, client): """Return True if node at {base_url} is a CN, False if it is an MN. Raise a DataONEException if it's not a functional CN or MN. """ node_pyxb = await client.get_capabilities() return d1_common.type_conversions.pyxb_get_type_name(node_pyxb) == "Nod...
python
async def is_cn(self, client): """Return True if node at {base_url} is a CN, False if it is an MN. Raise a DataONEException if it's not a functional CN or MN. """ node_pyxb = await client.get_capabilities() return d1_common.type_conversions.pyxb_get_type_name(node_pyxb) == "Nod...
[ "async", "def", "is_cn", "(", "self", ",", "client", ")", ":", "node_pyxb", "=", "await", "client", ".", "get_capabilities", "(", ")", "return", "d1_common", ".", "type_conversions", ".", "pyxb_get_type_name", "(", "node_pyxb", ")", "==", "\"NodeList\"" ]
Return True if node at {base_url} is a CN, False if it is an MN. Raise a DataONEException if it's not a functional CN or MN.
[ "Return", "True", "if", "node", "at", "{", "base_url", "}", "is", "a", "CN", "False", "if", "it", "is", "an", "MN", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L566-L573
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.probe_node_type_major
async def probe_node_type_major(self, client): """Determine if import source node is a CN or MN and which major version API to use.""" try: node_pyxb = await self.get_node_doc(client) except d1_common.types.exceptions.DataONEException as e: raise django.core.manag...
python
async def probe_node_type_major(self, client): """Determine if import source node is a CN or MN and which major version API to use.""" try: node_pyxb = await self.get_node_doc(client) except d1_common.types.exceptions.DataONEException as e: raise django.core.manag...
[ "async", "def", "probe_node_type_major", "(", "self", ",", "client", ")", ":", "try", ":", "node_pyxb", "=", "await", "self", ".", "get_node_doc", "(", "client", ")", "except", "d1_common", ".", "types", ".", "exceptions", ".", "DataONEException", "as", "e",...
Determine if import source node is a CN or MN and which major version API to use.
[ "Determine", "if", "import", "source", "node", "is", "a", "CN", "or", "MN", "and", "which", "major", "version", "API", "to", "use", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L583-L617
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.find_node
def find_node(self, node_list_pyxb, base_url): """Search NodeList for Node that has {base_url}. Return matching Node or None """ for node_pyxb in node_list_pyxb.node: if node_pyxb.baseURL == base_url: return node_pyxb
python
def find_node(self, node_list_pyxb, base_url): """Search NodeList for Node that has {base_url}. Return matching Node or None """ for node_pyxb in node_list_pyxb.node: if node_pyxb.baseURL == base_url: return node_pyxb
[ "def", "find_node", "(", "self", ",", "node_list_pyxb", ",", "base_url", ")", ":", "for", "node_pyxb", "in", "node_list_pyxb", ".", "node", ":", "if", "node_pyxb", ".", "baseURL", "==", "base_url", ":", "return", "node_pyxb" ]
Search NodeList for Node that has {base_url}. Return matching Node or None
[ "Search", "NodeList", "for", "Node", "that", "has", "{", "base_url", "}", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L619-L627
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.assert_is_known_node_id
def assert_is_known_node_id(self, node_list_pyxb, node_id): """When importing from a CN, ensure that the NodeID which the ObjectList will be filtered by is known to the CN.""" node_pyxb = self.find_node_by_id(node_list_pyxb, node_id) assert node_pyxb is not None, ( "The NodeI...
python
def assert_is_known_node_id(self, node_list_pyxb, node_id): """When importing from a CN, ensure that the NodeID which the ObjectList will be filtered by is known to the CN.""" node_pyxb = self.find_node_by_id(node_list_pyxb, node_id) assert node_pyxb is not None, ( "The NodeI...
[ "def", "assert_is_known_node_id", "(", "self", ",", "node_list_pyxb", ",", "node_id", ")", ":", "node_pyxb", "=", "self", ".", "find_node_by_id", "(", "node_list_pyxb", ",", "node_id", ")", "assert", "node_pyxb", "is", "not", "None", ",", "(", "\"The NodeID of t...
When importing from a CN, ensure that the NodeID which the ObjectList will be filtered by is known to the CN.
[ "When", "importing", "from", "a", "CN", "ensure", "that", "the", "NodeID", "which", "the", "ObjectList", "will", "be", "filtered", "by", "is", "known", "to", "the", "CN", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L629-L636
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.find_node_api_version
def find_node_api_version(self, node_pyxb): """Find the highest API major version supported by node.""" max_major = 0 for s in node_pyxb.services.service: max_major = max(max_major, int(s.version[1:])) return max_major
python
def find_node_api_version(self, node_pyxb): """Find the highest API major version supported by node.""" max_major = 0 for s in node_pyxb.services.service: max_major = max(max_major, int(s.version[1:])) return max_major
[ "def", "find_node_api_version", "(", "self", ",", "node_pyxb", ")", ":", "max_major", "=", "0", "for", "s", "in", "node_pyxb", ".", "services", ".", "service", ":", "max_major", "=", "max", "(", "max_major", ",", "int", "(", "s", ".", "version", "[", "...
Find the highest API major version supported by node.
[ "Find", "the", "highest", "API", "major", "version", "supported", "by", "node", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L638-L643
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
Command.find_node_by_id
def find_node_by_id(self, node_list_pyxb, node_id): """Search NodeList for Node with {node_id}. Return matching Node or None """ for node_pyxb in node_list_pyxb.node: # if node_pyxb.baseURL == base_url: if d1_common.xml.get_req_val(node_pyxb.identifier) == node_...
python
def find_node_by_id(self, node_list_pyxb, node_id): """Search NodeList for Node with {node_id}. Return matching Node or None """ for node_pyxb in node_list_pyxb.node: # if node_pyxb.baseURL == base_url: if d1_common.xml.get_req_val(node_pyxb.identifier) == node_...
[ "def", "find_node_by_id", "(", "self", ",", "node_list_pyxb", ",", "node_id", ")", ":", "for", "node_pyxb", "in", "node_list_pyxb", ".", "node", ":", "# if node_pyxb.baseURL == base_url:", "if", "d1_common", ".", "xml", ".", "get_req_val", "(", "node_pyxb", ".", ...
Search NodeList for Node with {node_id}. Return matching Node or None
[ "Search", "NodeList", "for", "Node", "with", "{", "node_id", "}", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L645-L654
genialis/resolwe
resolwe/flow/tasks.py
celery_run
def celery_run(data_id, runtime_dir, argv): """Run process executor. :param data_id: The id of the :class:`~resolwe.flow.models.Data` object to be processed. :param runtime_dir: The directory from which to run the executor. :param argv: The argument vector used to run the executor. :param v...
python
def celery_run(data_id, runtime_dir, argv): """Run process executor. :param data_id: The id of the :class:`~resolwe.flow.models.Data` object to be processed. :param runtime_dir: The directory from which to run the executor. :param argv: The argument vector used to run the executor. :param v...
[ "def", "celery_run", "(", "data_id", ",", "runtime_dir", ",", "argv", ")", ":", "subprocess", ".", "Popen", "(", "argv", ",", "cwd", "=", "runtime_dir", ",", "stdin", "=", "subprocess", ".", "DEVNULL", ")", ".", "wait", "(", ")" ]
Run process executor. :param data_id: The id of the :class:`~resolwe.flow.models.Data` object to be processed. :param runtime_dir: The directory from which to run the executor. :param argv: The argument vector used to run the executor. :param verbosity: The logging verbosity level.
[ "Run", "process", "executor", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/tasks.py#L22-L35
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta.py
archive_sciobj
def archive_sciobj(pid): """Set the status of an object to archived. Preconditions: - The object with the pid is verified to exist. - The object is not a replica. - The object is not archived. """ sciobj_model = d1_gmn.app.model_util.get_sci_model(pid) sciobj_model.is_archived = True ...
python
def archive_sciobj(pid): """Set the status of an object to archived. Preconditions: - The object with the pid is verified to exist. - The object is not a replica. - The object is not archived. """ sciobj_model = d1_gmn.app.model_util.get_sci_model(pid) sciobj_model.is_archived = True ...
[ "def", "archive_sciobj", "(", "pid", ")", ":", "sciobj_model", "=", "d1_gmn", ".", "app", ".", "model_util", ".", "get_sci_model", "(", "pid", ")", "sciobj_model", ".", "is_archived", "=", "True", "sciobj_model", ".", "save", "(", ")", "_update_modified_timest...
Set the status of an object to archived. Preconditions: - The object with the pid is verified to exist. - The object is not a replica. - The object is not archived.
[ "Set", "the", "status", "of", "an", "object", "to", "archived", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta.py#L48-L60
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta.py
create_or_update
def create_or_update(sysmeta_pyxb, sciobj_url=None): """Create or update database representation of a System Metadata object and closely related internal state. - If ``sciobj_url`` is not passed on create, storage in the internal sciobj store is assumed - If ``sciobj_url`` is passed on create, it...
python
def create_or_update(sysmeta_pyxb, sciobj_url=None): """Create or update database representation of a System Metadata object and closely related internal state. - If ``sciobj_url`` is not passed on create, storage in the internal sciobj store is assumed - If ``sciobj_url`` is passed on create, it...
[ "def", "create_or_update", "(", "sysmeta_pyxb", ",", "sciobj_url", "=", "None", ")", ":", "# TODO: Make sure that old sections are removed if not included in update.", "pid", "=", "d1_common", ".", "xml", ".", "get_req_val", "(", "sysmeta_pyxb", ".", "identifier", ")", ...
Create or update database representation of a System Metadata object and closely related internal state. - If ``sciobj_url`` is not passed on create, storage in the internal sciobj store is assumed - If ``sciobj_url`` is passed on create, it can reference a location in the internal sciobj store...
[ "Create", "or", "update", "database", "representation", "of", "a", "System", "Metadata", "object", "and", "closely", "related", "internal", "state", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta.py#L78-L129
DataONEorg/d1_python
gmn/src/d1_gmn/app/sysmeta.py
_access_policy_pyxb_to_model
def _access_policy_pyxb_to_model(sci_model, sysmeta_pyxb): """Create or update the database representation of the sysmeta_pyxb access policy. If called without an access policy, any existing permissions on the object are removed and the access policy for the rights holder is recreated. Preconditions: ...
python
def _access_policy_pyxb_to_model(sci_model, sysmeta_pyxb): """Create or update the database representation of the sysmeta_pyxb access policy. If called without an access policy, any existing permissions on the object are removed and the access policy for the rights holder is recreated. Preconditions: ...
[ "def", "_access_policy_pyxb_to_model", "(", "sci_model", ",", "sysmeta_pyxb", ")", ":", "_delete_existing_access_policy", "(", "sysmeta_pyxb", ")", "# Add an implicit allow rule with all permissions for the rights holder.", "allow_rights_holder", "=", "d1_common", ".", "types", "...
Create or update the database representation of the sysmeta_pyxb access policy. If called without an access policy, any existing permissions on the object are removed and the access policy for the rights holder is recreated. Preconditions: - Each subject has been verified to a valid DataONE account....
[ "Create", "or", "update", "the", "database", "representation", "of", "the", "sysmeta_pyxb", "access", "policy", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sysmeta.py#L282-L321
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import-multiprocess.py
Command.add_arguments
def add_arguments(self, parser): """Args: parser: """ parser.description = __doc__ parser.formatter_class = argparse.RawDescriptionHelpFormatter parser.add_argument("--debug", action="store_true", help="Debug level logging") parser.add_argument( "--f...
python
def add_arguments(self, parser): """Args: parser: """ parser.description = __doc__ parser.formatter_class = argparse.RawDescriptionHelpFormatter parser.add_argument("--debug", action="store_true", help="Debug level logging") parser.add_argument( "--f...
[ "def", "add_arguments", "(", "self", ",", "parser", ")", ":", "parser", ".", "description", "=", "__doc__", "parser", ".", "formatter_class", "=", "argparse", ".", "RawDescriptionHelpFormatter", "parser", ".", "add_argument", "(", "\"--debug\"", ",", "action", "...
Args: parser:
[ "Args", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import-multiprocess.py#L81-L156
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import-multiprocess.py
Command.handle
def handle(self, *args, **opt): """Args: *args: **opt: """ d1_gmn.app.management.commands.util.util.log_setup(opt["debug"]) logging.info( "Running management command: {}".format( __name__ ) # util.get_command_name()) ) ...
python
def handle(self, *args, **opt): """Args: *args: **opt: """ d1_gmn.app.management.commands.util.util.log_setup(opt["debug"]) logging.info( "Running management command: {}".format( __name__ ) # util.get_command_name()) ) ...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "opt", ")", ":", "d1_gmn", ".", "app", ".", "management", ".", "commands", ".", "util", ".", "util", ".", "log_setup", "(", "opt", "[", "\"debug\"", "]", ")", "logging", ".", "info", ...
Args: *args: **opt:
[ "Args", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import-multiprocess.py#L158-L183
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import-multiprocess.py
Command._create_log_entry
def _create_log_entry(self, log_record_pyxb): """Args: log_record_pyxb: """ event_log_model = d1_gmn.app.event_log.create_log_entry( d1_gmn.app.model_util.get_sci_model( d1_common.xml.get_req_val(log_record_pyxb.identifier) ), log_rec...
python
def _create_log_entry(self, log_record_pyxb): """Args: log_record_pyxb: """ event_log_model = d1_gmn.app.event_log.create_log_entry( d1_gmn.app.model_util.get_sci_model( d1_common.xml.get_req_val(log_record_pyxb.identifier) ), log_rec...
[ "def", "_create_log_entry", "(", "self", ",", "log_record_pyxb", ")", ":", "event_log_model", "=", "d1_gmn", ".", "app", ".", "event_log", ".", "create_log_entry", "(", "d1_gmn", ".", "app", ".", "model_util", ".", "get_sci_model", "(", "d1_common", ".", "xml"...
Args: log_record_pyxb:
[ "Args", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import-multiprocess.py#L340-L358
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import-multiprocess.py
Command._download_source_sciobj_bytes_to_store
def _download_source_sciobj_bytes_to_store(self, client, pid): """Args: client: pid: """ if d1_gmn.app.sciobj_store.is_existing_sciobj_file(pid): self._events.log_and_count( "Skipped download of existing sciobj bytes", 'pid="{}"'.format(pid) ) ...
python
def _download_source_sciobj_bytes_to_store(self, client, pid): """Args: client: pid: """ if d1_gmn.app.sciobj_store.is_existing_sciobj_file(pid): self._events.log_and_count( "Skipped download of existing sciobj bytes", 'pid="{}"'.format(pid) ) ...
[ "def", "_download_source_sciobj_bytes_to_store", "(", "self", ",", "client", ",", "pid", ")", ":", "if", "d1_gmn", ".", "app", ".", "sciobj_store", ".", "is_existing_sciobj_file", "(", "pid", ")", ":", "self", ".", "_events", ".", "log_and_count", "(", "\"Skip...
Args: client: pid:
[ "Args", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import-multiprocess.py#L369-L383
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import-multiprocess.py
Command._assert_path_is_dir
def _assert_path_is_dir(self, dir_path): """Args: dir_path: """ if not os.path.isdir(dir_path): raise django.core.management.base.CommandError( 'Invalid dir path. path="{}"'.format(dir_path) )
python
def _assert_path_is_dir(self, dir_path): """Args: dir_path: """ if not os.path.isdir(dir_path): raise django.core.management.base.CommandError( 'Invalid dir path. path="{}"'.format(dir_path) )
[ "def", "_assert_path_is_dir", "(", "self", ",", "dir_path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "dir_path", ")", ":", "raise", "django", ".", "core", ".", "management", ".", "base", ".", "CommandError", "(", "'Invalid dir path. pat...
Args: dir_path:
[ "Args", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import-multiprocess.py#L414-L423
DataONEorg/d1_python
lib_common/src/d1_common/cert/view_subject_info.py
deserialize_subject_info
def deserialize_subject_info(subject_info_xml_path): """Deserialize a SubjectInfo XML file to a PyXB object.""" try: with open(subject_info_xml_path) as f: return d1_common.xml.deserialize(f.read()) except ValueError as e: raise d1_common.types.exceptions.InvalidToken( ...
python
def deserialize_subject_info(subject_info_xml_path): """Deserialize a SubjectInfo XML file to a PyXB object.""" try: with open(subject_info_xml_path) as f: return d1_common.xml.deserialize(f.read()) except ValueError as e: raise d1_common.types.exceptions.InvalidToken( ...
[ "def", "deserialize_subject_info", "(", "subject_info_xml_path", ")", ":", "try", ":", "with", "open", "(", "subject_info_xml_path", ")", "as", "f", ":", "return", "d1_common", ".", "xml", ".", "deserialize", "(", "f", ".", "read", "(", ")", ")", "except", ...
Deserialize a SubjectInfo XML file to a PyXB object.
[ "Deserialize", "a", "SubjectInfo", "XML", "file", "to", "a", "PyXB", "object", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/view_subject_info.py#L47-L58
DataONEorg/d1_python
lib_client/src/d1_client/session.py
Session.HEAD
def HEAD(self, rest_path_list, **kwargs): """Send a HEAD request. See requests.sessions.request for optional parameters. :returns: Response object """ kwargs.setdefault("allow_redirects", False) return self._request("HEAD", rest_path_list, **kwargs)
python
def HEAD(self, rest_path_list, **kwargs): """Send a HEAD request. See requests.sessions.request for optional parameters. :returns: Response object """ kwargs.setdefault("allow_redirects", False) return self._request("HEAD", rest_path_list, **kwargs)
[ "def", "HEAD", "(", "self", ",", "rest_path_list", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"allow_redirects\"", ",", "False", ")", "return", "self", ".", "_request", "(", "\"HEAD\"", ",", "rest_path_list", ",", "*", "*", "k...
Send a HEAD request. See requests.sessions.request for optional parameters. :returns: Response object
[ "Send", "a", "HEAD", "request", ".", "See", "requests", ".", "sessions", ".", "request", "for", "optional", "parameters", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L191-L198
DataONEorg/d1_python
lib_client/src/d1_client/session.py
Session.POST
def POST(self, rest_path_list, **kwargs): """Send a POST request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. To post regular data, pass a string, iterator or generator as the ``data`` argument. To post a multipart stream, pass a dict...
python
def POST(self, rest_path_list, **kwargs): """Send a POST request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. To post regular data, pass a string, iterator or generator as the ``data`` argument. To post a multipart stream, pass a dict...
[ "def", "POST", "(", "self", ",", "rest_path_list", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "kwargs", ".", "pop", "(", "\"fields\"", ",", "None", ")", "if", "fields", "is", "not", "None", ":", "return", "self", ".", "_send_mmp_stream", "(", ...
Send a POST request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. To post regular data, pass a string, iterator or generator as the ``data`` argument. To post a multipart stream, pass a dictionary of multipart elements as the ``fields`` argume...
[ "Send", "a", "POST", "request", "with", "optional", "streaming", "multipart", "encoding", ".", "See", "requests", ".", "sessions", ".", "request", "for", "optional", "parameters", ".", "To", "post", "regular", "data", "pass", "a", "string", "iterator", "or", ...
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L200-L220
DataONEorg/d1_python
lib_client/src/d1_client/session.py
Session.PUT
def PUT(self, rest_path_list, **kwargs): """Send a PUT request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. See post() for parameters. :returns: Response object """ fields = kwargs.pop("fields", None) if fields is no...
python
def PUT(self, rest_path_list, **kwargs): """Send a PUT request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. See post() for parameters. :returns: Response object """ fields = kwargs.pop("fields", None) if fields is no...
[ "def", "PUT", "(", "self", ",", "rest_path_list", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "kwargs", ".", "pop", "(", "\"fields\"", ",", "None", ")", "if", "fields", "is", "not", "None", ":", "return", "self", ".", "_send_mmp_stream", "(", "...
Send a PUT request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. See post() for parameters. :returns: Response object
[ "Send", "a", "PUT", "request", "with", "optional", "streaming", "multipart", "encoding", ".", "See", "requests", ".", "sessions", ".", "request", "for", "optional", "parameters", ".", "See", "post", "()", "for", "parameters", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L222-L233
DataONEorg/d1_python
lib_client/src/d1_client/session.py
Session.get_curl_command_line
def get_curl_command_line(self, method, url, **kwargs): """Get request as cURL command line for debugging.""" if kwargs.get("query"): url = "{}?{}".format(url, d1_common.url.urlencode(kwargs["query"])) curl_list = ["curl"] if method.lower() == "head": curl_list.ap...
python
def get_curl_command_line(self, method, url, **kwargs): """Get request as cURL command line for debugging.""" if kwargs.get("query"): url = "{}?{}".format(url, d1_common.url.urlencode(kwargs["query"])) curl_list = ["curl"] if method.lower() == "head": curl_list.ap...
[ "def", "get_curl_command_line", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "\"query\"", ")", ":", "url", "=", "\"{}?{}\"", ".", "format", "(", "url", ",", "d1_common", ".", "url", ".", ...
Get request as cURL command line for debugging.
[ "Get", "request", "as", "cURL", "command", "line", "for", "debugging", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L252-L264
DataONEorg/d1_python
lib_client/src/d1_client/session.py
Session.dump_request_and_response
def dump_request_and_response(self, response): """Return a string containing a nicely formatted representation of the request and response objects for logging and debugging. - Note: Does not work if the request or response body is a MultipartEncoder object. """ if res...
python
def dump_request_and_response(self, response): """Return a string containing a nicely formatted representation of the request and response objects for logging and debugging. - Note: Does not work if the request or response body is a MultipartEncoder object. """ if res...
[ "def", "dump_request_and_response", "(", "self", ",", "response", ")", ":", "if", "response", ".", "reason", "is", "None", ":", "response", ".", "reason", "=", "\"<unknown>\"", "return", "d1_client", ".", "util", ".", "normalize_request_response_dump", "(", "req...
Return a string containing a nicely formatted representation of the request and response objects for logging and debugging. - Note: Does not work if the request or response body is a MultipartEncoder object.
[ "Return", "a", "string", "containing", "a", "nicely", "formatted", "representation", "of", "the", "request", "and", "response", "objects", "for", "logging", "and", "debugging", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L266-L278