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
DataONEorg/d1_python
lib_common/src/d1_common/multipart.py
is_multipart
def is_multipart(header_dict): """ Args: header_dict : CaseInsensitiveDict Returns: bool: ``True`` if ``header_dict`` has a Content-Type key (case insensitive) with value that begins with 'multipart'. """ return ( {k.lower(): v for k, v in header_dict.items()} .get('content-ty...
python
def is_multipart(header_dict): """ Args: header_dict : CaseInsensitiveDict Returns: bool: ``True`` if ``header_dict`` has a Content-Type key (case insensitive) with value that begins with 'multipart'. """ return ( {k.lower(): v for k, v in header_dict.items()} .get('content-ty...
[ "def", "is_multipart", "(", "header_dict", ")", ":", "return", "(", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "header_dict", ".", "items", "(", ")", "}", ".", "get", "(", "'content-type'", ",", "''", ")", ".", "start...
Args: header_dict : CaseInsensitiveDict Returns: bool: ``True`` if ``header_dict`` has a Content-Type key (case insensitive) with value that begins with 'multipart'.
[ "Args", ":", "header_dict", ":", "CaseInsensitiveDict" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/multipart.py#L90-L103
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/resolver/object_tree_resolver.py
Resolver._split_path_by_reserved_name
def _split_path_by_reserved_name(self, path): """Return: object_tree_path, resolver, controlled_path.""" for i, e in enumerate(path): if e in self._resolvers or e == self._get_readme_filename(): return path[:i], path[i], path[i + 1 :] raise d1_onedrive.impl.onedrive_e...
python
def _split_path_by_reserved_name(self, path): """Return: object_tree_path, resolver, controlled_path.""" for i, e in enumerate(path): if e in self._resolvers or e == self._get_readme_filename(): return path[:i], path[i], path[i + 1 :] raise d1_onedrive.impl.onedrive_e...
[ "def", "_split_path_by_reserved_name", "(", "self", ",", "path", ")", ":", "for", "i", ",", "e", "in", "enumerate", "(", "path", ")", ":", "if", "e", "in", "self", ".", "_resolvers", "or", "e", "==", "self", ".", "_get_readme_filename", "(", ")", ":", ...
Return: object_tree_path, resolver, controlled_path.
[ "Return", ":", "object_tree_path", "resolver", "controlled_path", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/object_tree_resolver.py#L245-L252
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/resolver/object_tree_resolver.py
Resolver._generate_readme_text
def _generate_readme_text(self, object_tree_path): """Generate a human readable description of the folder in text format.""" wdef_folder = self._object_tree.get_source_tree_folder(object_tree_path) res = StringIO() if len(object_tree_path): folder_name = object_tree_path[-1]...
python
def _generate_readme_text(self, object_tree_path): """Generate a human readable description of the folder in text format.""" wdef_folder = self._object_tree.get_source_tree_folder(object_tree_path) res = StringIO() if len(object_tree_path): folder_name = object_tree_path[-1]...
[ "def", "_generate_readme_text", "(", "self", ",", "object_tree_path", ")", ":", "wdef_folder", "=", "self", ".", "_object_tree", ".", "get_source_tree_folder", "(", "object_tree_path", ")", "res", "=", "StringIO", "(", ")", "if", "len", "(", "object_tree_path", ...
Generate a human readable description of the folder in text format.
[ "Generate", "a", "human", "readable", "description", "of", "the", "folder", "in", "text", "format", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/object_tree_resolver.py#L272-L311
genialis/resolwe
resolwe/flow/serializers/collection.py
CollectionSerializer._serialize_data
def _serialize_data(self, data): """Return serialized data or list of ids, depending on `hydrate_data` query param.""" if self.request and self.request.query_params.get('hydrate_data', False): serializer = DataSerializer(data, many=True, read_only=True) serializer.bind('data', se...
python
def _serialize_data(self, data): """Return serialized data or list of ids, depending on `hydrate_data` query param.""" if self.request and self.request.query_params.get('hydrate_data', False): serializer = DataSerializer(data, many=True, read_only=True) serializer.bind('data', se...
[ "def", "_serialize_data", "(", "self", ",", "data", ")", ":", "if", "self", ".", "request", "and", "self", ".", "request", ".", "query_params", ".", "get", "(", "'hydrate_data'", ",", "False", ")", ":", "serializer", "=", "DataSerializer", "(", "data", "...
Return serialized data or list of ids, depending on `hydrate_data` query param.
[ "Return", "serialized", "data", "or", "list", "of", "ids", "depending", "on", "hydrate_data", "query", "param", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/collection.py#L47-L54
genialis/resolwe
resolwe/flow/serializers/collection.py
CollectionSerializer._filter_queryset
def _filter_queryset(self, perms, queryset): """Filter object objects by permissions of user in request.""" user = self.request.user if self.request else AnonymousUser() return get_objects_for_user(user, perms, queryset)
python
def _filter_queryset(self, perms, queryset): """Filter object objects by permissions of user in request.""" user = self.request.user if self.request else AnonymousUser() return get_objects_for_user(user, perms, queryset)
[ "def", "_filter_queryset", "(", "self", ",", "perms", ",", "queryset", ")", ":", "user", "=", "self", ".", "request", ".", "user", "if", "self", ".", "request", "else", "AnonymousUser", "(", ")", "return", "get_objects_for_user", "(", "user", ",", "perms",...
Filter object objects by permissions of user in request.
[ "Filter", "object", "objects", "by", "permissions", "of", "user", "in", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/collection.py#L56-L59
genialis/resolwe
resolwe/flow/serializers/collection.py
CollectionSerializer.get_data
def get_data(self, collection): """Return serialized list of data objects on collection that user has `view` permission on.""" data = self._filter_queryset('view_data', collection.data.all()) return self._serialize_data(data)
python
def get_data(self, collection): """Return serialized list of data objects on collection that user has `view` permission on.""" data = self._filter_queryset('view_data', collection.data.all()) return self._serialize_data(data)
[ "def", "get_data", "(", "self", ",", "collection", ")", ":", "data", "=", "self", ".", "_filter_queryset", "(", "'view_data'", ",", "collection", ".", "data", ".", "all", "(", ")", ")", "return", "self", ".", "_serialize_data", "(", "data", ")" ]
Return serialized list of data objects on collection that user has `view` permission on.
[ "Return", "serialized", "list", "of", "data", "objects", "on", "collection", "that", "user", "has", "view", "permission", "on", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/collection.py#L61-L65
genialis/resolwe
resolwe/flow/serializers/collection.py
CollectionSerializer.get_fields
def get_fields(self): """Dynamically adapt fields based on the current request.""" fields = super(CollectionSerializer, self).get_fields() if self.request.method == "GET": fields['data'] = serializers.SerializerMethodField() else: fields['data'] = serializers.Pri...
python
def get_fields(self): """Dynamically adapt fields based on the current request.""" fields = super(CollectionSerializer, self).get_fields() if self.request.method == "GET": fields['data'] = serializers.SerializerMethodField() else: fields['data'] = serializers.Pri...
[ "def", "get_fields", "(", "self", ")", ":", "fields", "=", "super", "(", "CollectionSerializer", ",", "self", ")", ".", "get_fields", "(", ")", "if", "self", ".", "request", ".", "method", "==", "\"GET\"", ":", "fields", "[", "'data'", "]", "=", "seria...
Dynamically adapt fields based on the current request.
[ "Dynamically", "adapt", "fields", "based", "on", "the", "current", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/collection.py#L67-L76
genialis/resolwe
resolwe/flow/engine.py
load_engines
def load_engines(manager, class_name, base_module, engines, class_key='ENGINE', engine_type='engine'): """Load engines.""" loaded_engines = {} for module_name_or_dict in engines: if not isinstance(module_name_or_dict, dict): module_name_or_dict = { class_key: module_name...
python
def load_engines(manager, class_name, base_module, engines, class_key='ENGINE', engine_type='engine'): """Load engines.""" loaded_engines = {} for module_name_or_dict in engines: if not isinstance(module_name_or_dict, dict): module_name_or_dict = { class_key: module_name...
[ "def", "load_engines", "(", "manager", ",", "class_name", ",", "base_module", ",", "engines", ",", "class_key", "=", "'ENGINE'", ",", "engine_type", "=", "'engine'", ")", ":", "loaded_engines", "=", "{", "}", "for", "module_name_or_dict", "in", "engines", ":",...
Load engines.
[ "Load", "engines", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/engine.py#L29-L86
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
is_sysmeta_pyxb
def is_sysmeta_pyxb(sysmeta_pyxb): """Args: sysmeta_pyxb: Object that may or may not be a SystemMetadata PyXB object. Returns: bool: - ``True`` if ``sysmeta_pyxb`` is a SystemMetadata PyXB object. - ``False`` if ``sysmeta_pyxb`` is not a PyXB object or is a PyXB object of a type...
python
def is_sysmeta_pyxb(sysmeta_pyxb): """Args: sysmeta_pyxb: Object that may or may not be a SystemMetadata PyXB object. Returns: bool: - ``True`` if ``sysmeta_pyxb`` is a SystemMetadata PyXB object. - ``False`` if ``sysmeta_pyxb`` is not a PyXB object or is a PyXB object of a type...
[ "def", "is_sysmeta_pyxb", "(", "sysmeta_pyxb", ")", ":", "return", "(", "d1_common", ".", "type_conversions", ".", "is_pyxb_d1_type", "(", "sysmeta_pyxb", ")", "and", "d1_common", ".", "type_conversions", ".", "pyxb_get_type_name", "(", "sysmeta_pyxb", ")", "==", ...
Args: sysmeta_pyxb: Object that may or may not be a SystemMetadata PyXB object. Returns: bool: - ``True`` if ``sysmeta_pyxb`` is a SystemMetadata PyXB object. - ``False`` if ``sysmeta_pyxb`` is not a PyXB object or is a PyXB object of a type other than SystemMetadata.
[ "Args", ":", "sysmeta_pyxb", ":", "Object", "that", "may", "or", "may", "not", "be", "a", "SystemMetadata", "PyXB", "object", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L126-L140
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
normalize_in_place
def normalize_in_place(sysmeta_pyxb, reset_timestamps=False): """Normalize SystemMetadata PyXB object in-place. Args: sysmeta_pyxb: SystemMetadata PyXB object to normalize. reset_timestamps: bool ``True``: Timestamps in the SystemMetadata are set to a standard value so that ...
python
def normalize_in_place(sysmeta_pyxb, reset_timestamps=False): """Normalize SystemMetadata PyXB object in-place. Args: sysmeta_pyxb: SystemMetadata PyXB object to normalize. reset_timestamps: bool ``True``: Timestamps in the SystemMetadata are set to a standard value so that ...
[ "def", "normalize_in_place", "(", "sysmeta_pyxb", ",", "reset_timestamps", "=", "False", ")", ":", "if", "sysmeta_pyxb", ".", "accessPolicy", "is", "not", "None", ":", "sysmeta_pyxb", ".", "accessPolicy", "=", "d1_common", ".", "wrap", ".", "access_policy", ".",...
Normalize SystemMetadata PyXB object in-place. Args: sysmeta_pyxb: SystemMetadata PyXB object to normalize. reset_timestamps: bool ``True``: Timestamps in the SystemMetadata are set to a standard value so that objects that are compared after normalization register as equivalent...
[ "Normalize", "SystemMetadata", "PyXB", "object", "in", "-", "place", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L143-L196
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
are_equivalent_pyxb
def are_equivalent_pyxb(a_pyxb, b_pyxb, ignore_timestamps=False): """Determine if SystemMetadata PyXB objects are semantically equivalent. Normalize then compare SystemMetadata PyXB objects for equivalency. Args: a_pyxb, b_pyxb : SystemMetadata PyXB objects to compare reset_timestamps: bool ...
python
def are_equivalent_pyxb(a_pyxb, b_pyxb, ignore_timestamps=False): """Determine if SystemMetadata PyXB objects are semantically equivalent. Normalize then compare SystemMetadata PyXB objects for equivalency. Args: a_pyxb, b_pyxb : SystemMetadata PyXB objects to compare reset_timestamps: bool ...
[ "def", "are_equivalent_pyxb", "(", "a_pyxb", ",", "b_pyxb", ",", "ignore_timestamps", "=", "False", ")", ":", "normalize_in_place", "(", "a_pyxb", ",", "ignore_timestamps", ")", "normalize_in_place", "(", "b_pyxb", ",", "ignore_timestamps", ")", "a_xml", "=", "d1_...
Determine if SystemMetadata PyXB objects are semantically equivalent. Normalize then compare SystemMetadata PyXB objects for equivalency. Args: a_pyxb, b_pyxb : SystemMetadata PyXB objects to compare reset_timestamps: bool ``True``: Timestamps in the SystemMetadata are set to a standard v...
[ "Determine", "if", "SystemMetadata", "PyXB", "objects", "are", "semantically", "equivalent", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L199-L230
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
are_equivalent_xml
def are_equivalent_xml(a_xml, b_xml, ignore_timestamps=False): """Determine if two SystemMetadata XML docs are semantically equivalent. Normalize then compare SystemMetadata XML docs for equivalency. Args: a_xml, b_xml: bytes UTF-8 encoded SystemMetadata XML docs to compare ignore_tim...
python
def are_equivalent_xml(a_xml, b_xml, ignore_timestamps=False): """Determine if two SystemMetadata XML docs are semantically equivalent. Normalize then compare SystemMetadata XML docs for equivalency. Args: a_xml, b_xml: bytes UTF-8 encoded SystemMetadata XML docs to compare ignore_tim...
[ "def", "are_equivalent_xml", "(", "a_xml", ",", "b_xml", ",", "ignore_timestamps", "=", "False", ")", ":", "\"\"\"Normalizes then compares SystemMetadata XML docs for equivalency.\n ``a_xml`` and ``b_xml`` should be utf-8 encoded DataONE System Metadata XML\n documents.\n \"\"\"", "retu...
Determine if two SystemMetadata XML docs are semantically equivalent. Normalize then compare SystemMetadata XML docs for equivalency. Args: a_xml, b_xml: bytes UTF-8 encoded SystemMetadata XML docs to compare ignore_timestamps: bool ``True``: Timestamps in the SystemMetadata are i...
[ "Determine", "if", "two", "SystemMetadata", "XML", "docs", "are", "semantically", "equivalent", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L233-L265
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
clear_elements
def clear_elements(sysmeta_pyxb, clear_replica=True, clear_serial_version=True): """{clear_replica} causes any replica information to be removed from the object. {clear_replica} ignores any differences in replica information, as this information is often different between MN and CN. """ if clear_r...
python
def clear_elements(sysmeta_pyxb, clear_replica=True, clear_serial_version=True): """{clear_replica} causes any replica information to be removed from the object. {clear_replica} ignores any differences in replica information, as this information is often different between MN and CN. """ if clear_r...
[ "def", "clear_elements", "(", "sysmeta_pyxb", ",", "clear_replica", "=", "True", ",", "clear_serial_version", "=", "True", ")", ":", "if", "clear_replica", ":", "sysmeta_pyxb", ".", "replica", "=", "None", "if", "clear_serial_version", ":", "sysmeta_pyxb", ".", ...
{clear_replica} causes any replica information to be removed from the object. {clear_replica} ignores any differences in replica information, as this information is often different between MN and CN.
[ "{", "clear_replica", "}", "causes", "any", "replica", "information", "to", "be", "removed", "from", "the", "object", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L268-L280
DataONEorg/d1_python
lib_common/src/d1_common/system_metadata.py
update_elements
def update_elements(dst_pyxb, src_pyxb, el_list): """Copy elements specified in ``el_list`` from ``src_pyxb`` to ``dst_pyxb`` Only elements that are children of root are supported. See SYSMETA_ROOT_CHILD_LIST. If an element in ``el_list`` does not exist in ``src_pyxb``, it is removed from ``dst_py...
python
def update_elements(dst_pyxb, src_pyxb, el_list): """Copy elements specified in ``el_list`` from ``src_pyxb`` to ``dst_pyxb`` Only elements that are children of root are supported. See SYSMETA_ROOT_CHILD_LIST. If an element in ``el_list`` does not exist in ``src_pyxb``, it is removed from ``dst_py...
[ "def", "update_elements", "(", "dst_pyxb", ",", "src_pyxb", ",", "el_list", ")", ":", "invalid_element_set", "=", "set", "(", "el_list", ")", "-", "set", "(", "SYSMETA_ROOT_CHILD_LIST", ")", "if", "invalid_element_set", ":", "raise", "ValueError", "(", "'Passed ...
Copy elements specified in ``el_list`` from ``src_pyxb`` to ``dst_pyxb`` Only elements that are children of root are supported. See SYSMETA_ROOT_CHILD_LIST. If an element in ``el_list`` does not exist in ``src_pyxb``, it is removed from ``dst_pyxb``.
[ "Copy", "elements", "specified", "in", "el_list", "from", "src_pyxb", "to", "dst_pyxb" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/system_metadata.py#L283-L301
genialis/resolwe
resolwe/permissions/utils.py
get_full_perm
def get_full_perm(perm, obj): """Join action with the content type of ``obj``. Permission is returned in the format of ``<action>_<object_type>``. """ ctype = ContentType.objects.get_for_model(obj) # Camel case class names are converted into a space-separated # content types, so spaces have to ...
python
def get_full_perm(perm, obj): """Join action with the content type of ``obj``. Permission is returned in the format of ``<action>_<object_type>``. """ ctype = ContentType.objects.get_for_model(obj) # Camel case class names are converted into a space-separated # content types, so spaces have to ...
[ "def", "get_full_perm", "(", "perm", ",", "obj", ")", ":", "ctype", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "obj", ")", "# Camel case class names are converted into a space-separated", "# content types, so spaces have to be removed.", "ctype", "=", ...
Join action with the content type of ``obj``. Permission is returned in the format of ``<action>_<object_type>``.
[ "Join", "action", "with", "the", "content", "type", "of", "obj", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L31-L41
genialis/resolwe
resolwe/permissions/utils.py
copy_permissions
def copy_permissions(src_obj, dest_obj): """Copy permissions form ``src_obj`` to ``dest_obj``.""" def _process_permission(codename, user_or_group, dest_obj, relabel): """Process single permission.""" if relabel: codename = change_perm_ctype(codename, dest_obj) if codename...
python
def copy_permissions(src_obj, dest_obj): """Copy permissions form ``src_obj`` to ``dest_obj``.""" def _process_permission(codename, user_or_group, dest_obj, relabel): """Process single permission.""" if relabel: codename = change_perm_ctype(codename, dest_obj) if codename...
[ "def", "copy_permissions", "(", "src_obj", ",", "dest_obj", ")", ":", "def", "_process_permission", "(", "codename", ",", "user_or_group", ",", "dest_obj", ",", "relabel", ")", ":", "\"\"\"Process single permission.\"\"\"", "if", "relabel", ":", "codename", "=", "...
Copy permissions form ``src_obj`` to ``dest_obj``.
[ "Copy", "permissions", "form", "src_obj", "to", "dest_obj", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L55-L76
genialis/resolwe
resolwe/permissions/utils.py
fetch_user
def fetch_user(query): """Get user by ``pk`` or ``username``. Raise error if it doesn't exist.""" user_filter = {'pk': query} if query.isdigit() else {'username': query} user_model = get_user_model() try: return user_model.objects.get(**user_filter) except user_model.DoesNotExist: r...
python
def fetch_user(query): """Get user by ``pk`` or ``username``. Raise error if it doesn't exist.""" user_filter = {'pk': query} if query.isdigit() else {'username': query} user_model = get_user_model() try: return user_model.objects.get(**user_filter) except user_model.DoesNotExist: r...
[ "def", "fetch_user", "(", "query", ")", ":", "user_filter", "=", "{", "'pk'", ":", "query", "}", "if", "query", ".", "isdigit", "(", ")", "else", "{", "'username'", ":", "query", "}", "user_model", "=", "get_user_model", "(", ")", "try", ":", "return",...
Get user by ``pk`` or ``username``. Raise error if it doesn't exist.
[ "Get", "user", "by", "pk", "or", "username", ".", "Raise", "error", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L79-L87
genialis/resolwe
resolwe/permissions/utils.py
fetch_group
def fetch_group(query): """Get group by ``pk`` or ``name``. Raise error if it doesn't exist.""" group_filter = {'pk': query} if query.isdigit() else {'name': query} try: return Group.objects.get(**group_filter) except Group.DoesNotExist: raise exceptions.ParseError("Unknown group: {}".f...
python
def fetch_group(query): """Get group by ``pk`` or ``name``. Raise error if it doesn't exist.""" group_filter = {'pk': query} if query.isdigit() else {'name': query} try: return Group.objects.get(**group_filter) except Group.DoesNotExist: raise exceptions.ParseError("Unknown group: {}".f...
[ "def", "fetch_group", "(", "query", ")", ":", "group_filter", "=", "{", "'pk'", ":", "query", "}", "if", "query", ".", "isdigit", "(", ")", "else", "{", "'name'", ":", "query", "}", "try", ":", "return", "Group", ".", "objects", ".", "get", "(", "*...
Get group by ``pk`` or ``name``. Raise error if it doesn't exist.
[ "Get", "group", "by", "pk", "or", "name", ".", "Raise", "error", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L90-L97
genialis/resolwe
resolwe/permissions/utils.py
check_owner_permission
def check_owner_permission(payload, allow_user_owner): """Raise ``PermissionDenied``if ``owner`` found in ``data``.""" for entity_type in ['users', 'groups']: for perm_type in ['add', 'remove']: for perms in payload.get(entity_type, {}).get(perm_type, {}).values(): if 'owner'...
python
def check_owner_permission(payload, allow_user_owner): """Raise ``PermissionDenied``if ``owner`` found in ``data``.""" for entity_type in ['users', 'groups']: for perm_type in ['add', 'remove']: for perms in payload.get(entity_type, {}).get(perm_type, {}).values(): if 'owner'...
[ "def", "check_owner_permission", "(", "payload", ",", "allow_user_owner", ")", ":", "for", "entity_type", "in", "[", "'users'", ",", "'groups'", "]", ":", "for", "perm_type", "in", "[", "'add'", ",", "'remove'", "]", ":", "for", "perms", "in", "payload", "...
Raise ``PermissionDenied``if ``owner`` found in ``data``.
[ "Raise", "PermissionDenied", "if", "owner", "found", "in", "data", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L100-L112
genialis/resolwe
resolwe/permissions/utils.py
check_public_permissions
def check_public_permissions(payload): """Raise ``PermissionDenied`` if public permissions are too open.""" allowed_public_permissions = ['view', 'add', 'download'] for perm_type in ['add', 'remove']: for perm in payload.get('public', {}).get(perm_type, []): if perm not in allowed_public...
python
def check_public_permissions(payload): """Raise ``PermissionDenied`` if public permissions are too open.""" allowed_public_permissions = ['view', 'add', 'download'] for perm_type in ['add', 'remove']: for perm in payload.get('public', {}).get(perm_type, []): if perm not in allowed_public...
[ "def", "check_public_permissions", "(", "payload", ")", ":", "allowed_public_permissions", "=", "[", "'view'", ",", "'add'", ",", "'download'", "]", "for", "perm_type", "in", "[", "'add'", ",", "'remove'", "]", ":", "for", "perm", "in", "payload", ".", "get"...
Raise ``PermissionDenied`` if public permissions are too open.
[ "Raise", "PermissionDenied", "if", "public", "permissions", "are", "too", "open", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L115-L121
genialis/resolwe
resolwe/permissions/utils.py
check_user_permissions
def check_user_permissions(payload, user_pk): """Raise ``PermissionDenied`` if ``payload`` includes ``user_pk``.""" for perm_type in ['add', 'remove']: user_pks = payload.get('users', {}).get(perm_type, {}).keys() if user_pk in user_pks: raise exceptions.PermissionDenied("You cannot ...
python
def check_user_permissions(payload, user_pk): """Raise ``PermissionDenied`` if ``payload`` includes ``user_pk``.""" for perm_type in ['add', 'remove']: user_pks = payload.get('users', {}).get(perm_type, {}).keys() if user_pk in user_pks: raise exceptions.PermissionDenied("You cannot ...
[ "def", "check_user_permissions", "(", "payload", ",", "user_pk", ")", ":", "for", "perm_type", "in", "[", "'add'", ",", "'remove'", "]", ":", "user_pks", "=", "payload", ".", "get", "(", "'users'", ",", "{", "}", ")", ".", "get", "(", "perm_type", ",",...
Raise ``PermissionDenied`` if ``payload`` includes ``user_pk``.
[ "Raise", "PermissionDenied", "if", "payload", "includes", "user_pk", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L124-L129
genialis/resolwe
resolwe/permissions/utils.py
remove_permission
def remove_permission(payload, permission): """Remove all occurrences of ``permission`` from ``payload``.""" payload = copy.deepcopy(payload) for entity_type in ['users', 'groups']: for perm_type in ['add', 'remove']: for perms in payload.get(entity_type, {}).get(perm_type, {}).values()...
python
def remove_permission(payload, permission): """Remove all occurrences of ``permission`` from ``payload``.""" payload = copy.deepcopy(payload) for entity_type in ['users', 'groups']: for perm_type in ['add', 'remove']: for perms in payload.get(entity_type, {}).get(perm_type, {}).values()...
[ "def", "remove_permission", "(", "payload", ",", "permission", ")", ":", "payload", "=", "copy", ".", "deepcopy", "(", "payload", ")", "for", "entity_type", "in", "[", "'users'", ",", "'groups'", "]", ":", "for", "perm_type", "in", "[", "'add'", ",", "'r...
Remove all occurrences of ``permission`` from ``payload``.
[ "Remove", "all", "occurrences", "of", "permission", "from", "payload", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L132-L147
genialis/resolwe
resolwe/permissions/utils.py
update_permission
def update_permission(obj, data): """Update object permissions.""" full_permissions = get_all_perms(obj) def apply_perm(perm_func, perms, entity): """Apply permissions using given ``perm_func``. ``perm_func`` is intended to be ``assign_perms`` or ``remove_perms`` shortcut function ...
python
def update_permission(obj, data): """Update object permissions.""" full_permissions = get_all_perms(obj) def apply_perm(perm_func, perms, entity): """Apply permissions using given ``perm_func``. ``perm_func`` is intended to be ``assign_perms`` or ``remove_perms`` shortcut function ...
[ "def", "update_permission", "(", "obj", ",", "data", ")", ":", "full_permissions", "=", "get_all_perms", "(", "obj", ")", "def", "apply_perm", "(", "perm_func", ",", "perms", ",", "entity", ")", ":", "\"\"\"Apply permissions using given ``perm_func``.\n\n ``per...
Update object permissions.
[ "Update", "object", "permissions", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L150-L207
genialis/resolwe
resolwe/permissions/utils.py
assign_contributor_permissions
def assign_contributor_permissions(obj, contributor=None): """Assign all permissions to object's contributor.""" for permission in get_all_perms(obj): assign_perm(permission, contributor if contributor else obj.contributor, obj)
python
def assign_contributor_permissions(obj, contributor=None): """Assign all permissions to object's contributor.""" for permission in get_all_perms(obj): assign_perm(permission, contributor if contributor else obj.contributor, obj)
[ "def", "assign_contributor_permissions", "(", "obj", ",", "contributor", "=", "None", ")", ":", "for", "permission", "in", "get_all_perms", "(", "obj", ")", ":", "assign_perm", "(", "permission", ",", "contributor", "if", "contributor", "else", "obj", ".", "co...
Assign all permissions to object's contributor.
[ "Assign", "all", "permissions", "to", "object", "s", "contributor", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/utils.py#L210-L213
genialis/resolwe
resolwe/flow/executors/local/run.py
FlowExecutor.start
async def start(self): """Start process execution.""" # Workaround for pylint issue #1469 # (https://github.com/PyCQA/pylint/issues/1469). self.proc = await subprocess.create_subprocess_exec( # pylint: disable=no-member *shlex.split(self.command), stdin=subproces...
python
async def start(self): """Start process execution.""" # Workaround for pylint issue #1469 # (https://github.com/PyCQA/pylint/issues/1469). self.proc = await subprocess.create_subprocess_exec( # pylint: disable=no-member *shlex.split(self.command), stdin=subproces...
[ "async", "def", "start", "(", "self", ")", ":", "# Workaround for pylint issue #1469", "# (https://github.com/PyCQA/pylint/issues/1469).", "self", ".", "proc", "=", "await", "subprocess", ".", "create_subprocess_exec", "(", "# pylint: disable=no-member", "*", "shlex", ".", ...
Start process execution.
[ "Start", "process", "execution", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/local/run.py#L31-L43
genialis/resolwe
resolwe/flow/executors/local/run.py
FlowExecutor.run_script
async def run_script(self, script): """Execute the script and save results.""" script = os.linesep.join(['set -x', 'set +B', script, 'exit']) + os.linesep self.proc.stdin.write(script.encode('utf-8')) await self.proc.stdin.drain() self.proc.stdin.close()
python
async def run_script(self, script): """Execute the script and save results.""" script = os.linesep.join(['set -x', 'set +B', script, 'exit']) + os.linesep self.proc.stdin.write(script.encode('utf-8')) await self.proc.stdin.drain() self.proc.stdin.close()
[ "async", "def", "run_script", "(", "self", ",", "script", ")", ":", "script", "=", "os", ".", "linesep", ".", "join", "(", "[", "'set -x'", ",", "'set +B'", ",", "script", ",", "'exit'", "]", ")", "+", "os", ".", "linesep", "self", ".", "proc", "."...
Execute the script and save results.
[ "Execute", "the", "script", "and", "save", "results", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/local/run.py#L45-L50
genialis/resolwe
resolwe/flow/executors/local/run.py
FlowExecutor.terminate
async def terminate(self): """Terminate a running script.""" self.proc.terminate() await asyncio.wait_for(self.proc.wait(), self.kill_delay) if self.proc.returncode is None: self.proc.kill() await self.proc.wait() await super().terminate()
python
async def terminate(self): """Terminate a running script.""" self.proc.terminate() await asyncio.wait_for(self.proc.wait(), self.kill_delay) if self.proc.returncode is None: self.proc.kill() await self.proc.wait() await super().terminate()
[ "async", "def", "terminate", "(", "self", ")", ":", "self", ".", "proc", ".", "terminate", "(", ")", "await", "asyncio", ".", "wait_for", "(", "self", ".", "proc", ".", "wait", "(", ")", ",", "self", ".", "kill_delay", ")", "if", "self", ".", "proc...
Terminate a running script.
[ "Terminate", "a", "running", "script", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/local/run.py#L58-L67
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener._make_connection
async def _make_connection(self): """Construct a connection to Redis.""" return await aioredis.create_redis( 'redis://{}:{}'.format( self._redis_params.get('host', 'localhost'), self._redis_params.get('port', 6379) ), db=int(self._redis...
python
async def _make_connection(self): """Construct a connection to Redis.""" return await aioredis.create_redis( 'redis://{}:{}'.format( self._redis_params.get('host', 'localhost'), self._redis_params.get('port', 6379) ), db=int(self._redis...
[ "async", "def", "_make_connection", "(", "self", ")", ":", "return", "await", "aioredis", ".", "create_redis", "(", "'redis://{}:{}'", ".", "format", "(", "self", ".", "_redis_params", ".", "get", "(", "'host'", ",", "'localhost'", ")", ",", "self", ".", "...
Construct a connection to Redis.
[ "Construct", "a", "connection", "to", "Redis", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L84-L92
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener._call_redis
async def _call_redis(self, meth, *args, **kwargs): """Perform a Redis call and handle connection dropping.""" while True: try: if not self._redis: self._redis = await self._make_connection() return await meth(self._redis, *args, **kwargs) ...
python
async def _call_redis(self, meth, *args, **kwargs): """Perform a Redis call and handle connection dropping.""" while True: try: if not self._redis: self._redis = await self._make_connection() return await meth(self._redis, *args, **kwargs) ...
[ "async", "def", "_call_redis", "(", "self", ",", "meth", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "try", ":", "if", "not", "self", ".", "_redis", ":", "self", ".", "_redis", "=", "await", "self", ".", "_make_connec...
Perform a Redis call and handle connection dropping.
[ "Perform", "a", "Redis", "call", "and", "handle", "connection", "dropping", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L94-L107
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.clear_queue
async def clear_queue(self): """Reset the executor queue channel to an empty state.""" conn = await self._make_connection() try: script = """ local keys = redis.call('KEYS', ARGV[1]) redis.call('DEL', unpack(keys)) """ await con...
python
async def clear_queue(self): """Reset the executor queue channel to an empty state.""" conn = await self._make_connection() try: script = """ local keys = redis.call('KEYS', ARGV[1]) redis.call('DEL', unpack(keys)) """ await con...
[ "async", "def", "clear_queue", "(", "self", ")", ":", "conn", "=", "await", "self", ".", "_make_connection", "(", ")", "try", ":", "script", "=", "\"\"\"\n local keys = redis.call('KEYS', ARGV[1])\n redis.call('DEL', unpack(keys))\n \"\"...
Reset the executor queue channel to an empty state.
[ "Reset", "the", "executor", "queue", "channel", "to", "an", "empty", "state", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L109-L123
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.terminate
def terminate(self): """Stop the standalone manager.""" logger.info(__( "Terminating Resolwe listener on channel '{}'.", state.MANAGER_EXECUTOR_CHANNELS.queue )) self._should_stop = True
python
def terminate(self): """Stop the standalone manager.""" logger.info(__( "Terminating Resolwe listener on channel '{}'.", state.MANAGER_EXECUTOR_CHANNELS.queue )) self._should_stop = True
[ "def", "terminate", "(", "self", ")", ":", "logger", ".", "info", "(", "__", "(", "\"Terminating Resolwe listener on channel '{}'.\"", ",", "state", ".", "MANAGER_EXECUTOR_CHANNELS", ".", "queue", ")", ")", "self", ".", "_should_stop", "=", "True" ]
Stop the standalone manager.
[ "Stop", "the", "standalone", "manager", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L145-L151
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener._queue_response_channel
def _queue_response_channel(self, obj): """Generate the feedback channel name from the object's id. :param obj: The Channels message object. """ return '{}.{}'.format(state.MANAGER_EXECUTOR_CHANNELS.queue_response, obj[ExecutorProtocol.DATA_ID])
python
def _queue_response_channel(self, obj): """Generate the feedback channel name from the object's id. :param obj: The Channels message object. """ return '{}.{}'.format(state.MANAGER_EXECUTOR_CHANNELS.queue_response, obj[ExecutorProtocol.DATA_ID])
[ "def", "_queue_response_channel", "(", "self", ",", "obj", ")", ":", "return", "'{}.{}'", ".", "format", "(", "state", ".", "MANAGER_EXECUTOR_CHANNELS", ".", "queue_response", ",", "obj", "[", "ExecutorProtocol", ".", "DATA_ID", "]", ")" ]
Generate the feedback channel name from the object's id. :param obj: The Channels message object.
[ "Generate", "the", "feedback", "channel", "name", "from", "the", "object", "s", "id", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L153-L158
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener._send_reply
async def _send_reply(self, obj, reply): """Send a reply with added standard fields back to executor. :param obj: The original Channels message object to which we're replying. :param reply: The message contents dictionary. The data id is added automatically (``reply`` is...
python
async def _send_reply(self, obj, reply): """Send a reply with added standard fields back to executor. :param obj: The original Channels message object to which we're replying. :param reply: The message contents dictionary. The data id is added automatically (``reply`` is...
[ "async", "def", "_send_reply", "(", "self", ",", "obj", ",", "reply", ")", ":", "reply", ".", "update", "(", "{", "ExecutorProtocol", ".", "DATA_ID", ":", "obj", "[", "ExecutorProtocol", ".", "DATA_ID", "]", ",", "}", ")", "await", "self", ".", "_call_...
Send a reply with added standard fields back to executor. :param obj: The original Channels message object to which we're replying. :param reply: The message contents dictionary. The data id is added automatically (``reply`` is modified in place).
[ "Send", "a", "reply", "with", "added", "standard", "fields", "back", "to", "executor", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L165-L176
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.hydrate_spawned_files
def hydrate_spawned_files(self, exported_files_mapper, filename, data_id): """Pop the given file's map from the exported files mapping. :param exported_files_mapper: The dict of file mappings this process produced. :param filename: The filename to format and remove from the ...
python
def hydrate_spawned_files(self, exported_files_mapper, filename, data_id): """Pop the given file's map from the exported files mapping. :param exported_files_mapper: The dict of file mappings this process produced. :param filename: The filename to format and remove from the ...
[ "def", "hydrate_spawned_files", "(", "self", ",", "exported_files_mapper", ",", "filename", ",", "data_id", ")", ":", "# JSON only has string dictionary keys, so the Data object id", "# needs to be stringified first.", "data_id", "=", "str", "(", "data_id", ")", "if", "file...
Pop the given file's map from the exported files mapping. :param exported_files_mapper: The dict of file mappings this process produced. :param filename: The filename to format and remove from the mapping. :param data_id: The id of the :meth:`~resolwe.flow.models.Data` ...
[ "Pop", "the", "given", "file", "s", "map", "from", "the", "exported", "files", "mapping", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L178-L203
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.handle_update
def handle_update(self, obj, internal_call=False): """Handle an incoming ``Data`` object update request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'update', 'data_id': [id of th...
python
def handle_update(self, obj, internal_call=False): """Handle an incoming ``Data`` object update request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'update', 'data_id': [id of th...
[ "def", "handle_update", "(", "self", ",", "obj", ",", "internal_call", "=", "False", ")", ":", "data_id", "=", "obj", "[", "ExecutorProtocol", ".", "DATA_ID", "]", "changeset", "=", "obj", "[", "ExecutorProtocol", ".", "UPDATE_CHANGESET", "]", "if", "not", ...
Handle an incoming ``Data`` object update request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'update', 'data_id': [id of the :class:`~resolwe.flow.models.Data` ...
[ "Handle", "an", "incoming", "Data", "object", "update", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L205-L331
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.handle_finish
def handle_finish(self, obj): """Handle an incoming ``Data`` finished processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'finish', 'data_id': [id of the :class:`~reso...
python
def handle_finish(self, obj): """Handle an incoming ``Data`` finished processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'finish', 'data_id': [id of the :class:`~reso...
[ "def", "handle_finish", "(", "self", ",", "obj", ")", ":", "data_id", "=", "obj", "[", "ExecutorProtocol", ".", "DATA_ID", "]", "logger", ".", "debug", "(", "__", "(", "\"Finishing Data with id {} (handle_finish).\"", ",", "data_id", ")", ",", "extra", "=", ...
Handle an incoming ``Data`` finished processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'finish', 'data_id': [id of the :class:`~resolwe.flow.models.Data` object ...
[ "Handle", "an", "incoming", "Data", "finished", "processing", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L333-L511
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.handle_abort
def handle_abort(self, obj): """Handle an incoming ``Data`` abort processing request. .. IMPORTANT:: This only makes manager's state consistent and doesn't affect Data object in any way. Any changes to the Data must be applied over ``handle_update`` method. ...
python
def handle_abort(self, obj): """Handle an incoming ``Data`` abort processing request. .. IMPORTANT:: This only makes manager's state consistent and doesn't affect Data object in any way. Any changes to the Data must be applied over ``handle_update`` method. ...
[ "def", "handle_abort", "(", "self", ",", "obj", ")", ":", "async_to_sync", "(", "consumer", ".", "send_event", ")", "(", "{", "WorkerProtocol", ".", "COMMAND", ":", "WorkerProtocol", ".", "ABORT", ",", "WorkerProtocol", ".", "DATA_ID", ":", "obj", "[", "Ex...
Handle an incoming ``Data`` abort processing request. .. IMPORTANT:: This only makes manager's state consistent and doesn't affect Data object in any way. Any changes to the Data must be applied over ``handle_update`` method. :param obj: The Channels message object...
[ "Handle", "an", "incoming", "Data", "abort", "processing", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L513-L538
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.handle_log
def handle_log(self, obj): """Handle an incoming log processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'log', 'message': [log message] } """ ...
python
def handle_log(self, obj): """Handle an incoming log processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'log', 'message': [log message] } """ ...
[ "def", "handle_log", "(", "self", ",", "obj", ")", ":", "record_dict", "=", "json", ".", "loads", "(", "obj", "[", "ExecutorProtocol", ".", "LOG_MESSAGE", "]", ")", "record_dict", "[", "'msg'", "]", "=", "record_dict", "[", "'msg'", "]", "executors_dir", ...
Handle an incoming log processing request. :param obj: The Channels message object. Command object format: .. code-block:: none { 'command': 'log', 'message': [log message] }
[ "Handle", "an", "incoming", "log", "processing", "request", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L540-L558
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.push_stats
async def push_stats(self): """Push current stats to Redis.""" snapshot = self._make_stats() try: serialized = json.dumps(snapshot) await self._call_redis(aioredis.Redis.set, state.MANAGER_LISTENER_STATS, serialized) await self._call_redis(aioredis.Redis.expir...
python
async def push_stats(self): """Push current stats to Redis.""" snapshot = self._make_stats() try: serialized = json.dumps(snapshot) await self._call_redis(aioredis.Redis.set, state.MANAGER_LISTENER_STATS, serialized) await self._call_redis(aioredis.Redis.expir...
[ "async", "def", "push_stats", "(", "self", ")", ":", "snapshot", "=", "self", ".", "_make_stats", "(", ")", "try", ":", "serialized", "=", "json", ".", "dumps", "(", "snapshot", ")", "await", "self", ".", "_call_redis", "(", "aioredis", ".", "Redis", "...
Push current stats to Redis.
[ "Push", "current", "stats", "to", "Redis", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L567-L583
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.check_critical_load
def check_critical_load(self): """Check for critical load and log an error if necessary.""" if self.load_avg.intervals['1m'].value > 1: if self.last_load_level == 1 and time.time() - self.last_load_log < 30: return self.last_load_log = time.time() self...
python
def check_critical_load(self): """Check for critical load and log an error if necessary.""" if self.load_avg.intervals['1m'].value > 1: if self.last_load_level == 1 and time.time() - self.last_load_log < 30: return self.last_load_log = time.time() self...
[ "def", "check_critical_load", "(", "self", ")", ":", "if", "self", ".", "load_avg", ".", "intervals", "[", "'1m'", "]", ".", "value", ">", "1", ":", "if", "self", ".", "last_load_level", "==", "1", "and", "time", ".", "time", "(", ")", "-", "self", ...
Check for critical load and log an error if necessary.
[ "Check", "for", "critical", "load", "and", "log", "an", "error", "if", "necessary", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L585-L609
genialis/resolwe
resolwe/flow/managers/listener.py
ExecutorListener.run
async def run(self): """Run the main listener run loop. Doesn't return until :meth:`terminate` is called. """ logger.info(__( "Starting Resolwe listener on channel '{}'.", state.MANAGER_EXECUTOR_CHANNELS.queue )) while not self._should_stop: ...
python
async def run(self): """Run the main listener run loop. Doesn't return until :meth:`terminate` is called. """ logger.info(__( "Starting Resolwe listener on channel '{}'.", state.MANAGER_EXECUTOR_CHANNELS.queue )) while not self._should_stop: ...
[ "async", "def", "run", "(", "self", ")", ":", "logger", ".", "info", "(", "__", "(", "\"Starting Resolwe listener on channel '{}'.\"", ",", "state", ".", "MANAGER_EXECUTOR_CHANNELS", ".", "queue", ")", ")", "while", "not", "self", ".", "_should_stop", ":", "aw...
Run the main listener run loop. Doesn't return until :meth:`terminate` is called.
[ "Run", "the", "main", "listener", "run", "loop", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/listener.py#L611-L671
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.dokanMain
def dokanMain(self, dokanOptions, dokanOperations): """Issue callback to start dokan drive. :param DokanOptions: drive options :type DokanOptions: DOKAN_OPTIONS :param DokanOperations: pointers implemented file system calls :type DokanOperations: DokanOperations :return:...
python
def dokanMain(self, dokanOptions, dokanOperations): """Issue callback to start dokan drive. :param DokanOptions: drive options :type DokanOptions: DOKAN_OPTIONS :param DokanOperations: pointers implemented file system calls :type DokanOperations: DokanOperations :return:...
[ "def", "dokanMain", "(", "self", ",", "dokanOptions", ",", "dokanOperations", ")", ":", "return", "int", "(", "self", ".", "dokanDLL", ".", "DokanMain", "(", "PDOKAN_OPTIONS", "(", "dokanOptions", ")", ",", "PDOKAN_OPERATIONS", "(", "dokanOperations", ")", ")"...
Issue callback to start dokan drive. :param DokanOptions: drive options :type DokanOptions: DOKAN_OPTIONS :param DokanOperations: pointers implemented file system calls :type DokanOperations: DokanOperations :return: error code :rtype: int
[ "Issue", "callback", "to", "start", "dokan", "drive", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L86-L101
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.createFile
def createFile( self, fileName, desiredAccess, shareMode, creationDisposition, flagsAndAttributes, dokanFileInfo, ): """Creates a file. :param fileName: name of file to create :type fileName: ctypes.c_wchar_p :param desiredAcce...
python
def createFile( self, fileName, desiredAccess, shareMode, creationDisposition, flagsAndAttributes, dokanFileInfo, ): """Creates a file. :param fileName: name of file to create :type fileName: ctypes.c_wchar_p :param desiredAcce...
[ "def", "createFile", "(", "self", ",", "fileName", ",", "desiredAccess", ",", "shareMode", ",", "creationDisposition", ",", "flagsAndAttributes", ",", "dokanFileInfo", ",", ")", ":", "return", "self", ".", "operations", "(", "'createFile'", ",", "fileName", ")" ...
Creates a file. :param fileName: name of file to create :type fileName: ctypes.c_wchar_p :param desiredAccess: desired access flags :type desiredAccess: ctypes.c_ulong :param shareMode: share mode flags :type shareMode: ctypes.c_ulong :param creationDisposition: ...
[ "Creates", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L141-L168
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.readFile
def readFile( self, fileName, buffer, numberOfBytesToRead, numberOfBytesRead, offset, dokanFileInfo, ): """Read a file. :param fileName: name of file to read :type fileName: ctypes.c_wchar_p :param buffer: buffer for content re...
python
def readFile( self, fileName, buffer, numberOfBytesToRead, numberOfBytesRead, offset, dokanFileInfo, ): """Read a file. :param fileName: name of file to read :type fileName: ctypes.c_wchar_p :param buffer: buffer for content re...
[ "def", "readFile", "(", "self", ",", "fileName", ",", "buffer", ",", "numberOfBytesToRead", ",", "numberOfBytesRead", ",", "offset", ",", "dokanFileInfo", ",", ")", ":", "try", ":", "ret", "=", "self", ".", "operations", "(", "'readFile'", ",", "fileName", ...
Read a file. :param fileName: name of file to read :type fileName: ctypes.c_wchar_p :param buffer: buffer for content read :type buffer: ctypes.c_void_p :param numberOfBytesToRead: number of bytes to read :type numberOfBytesToRead: ctypes.c_ulong :param numberOfB...
[ "Read", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L222-L262
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.writeFile
def writeFile( self, fileName, buffer, numberOfBytesToWrite, numberOfBytesWritten, offset, dokanFileInfo, ): """Read a file. :param fileName: name of file to write :type fileName: ctypes.c_wchar_p :param buffer: buffer to write...
python
def writeFile( self, fileName, buffer, numberOfBytesToWrite, numberOfBytesWritten, offset, dokanFileInfo, ): """Read a file. :param fileName: name of file to write :type fileName: ctypes.c_wchar_p :param buffer: buffer to write...
[ "def", "writeFile", "(", "self", ",", "fileName", ",", "buffer", ",", "numberOfBytesToWrite", ",", "numberOfBytesWritten", ",", "offset", ",", "dokanFileInfo", ",", ")", ":", "return", "self", ".", "operations", "(", "'writeFile'", ",", "fileName", ",", "buffe...
Read a file. :param fileName: name of file to write :type fileName: ctypes.c_wchar_p :param buffer: buffer to write :type buffer: ctypes.c_void_p :param numberOfBytesToWrite: number of bytes to write :type numberOfBytesToWrite: ctypes.c_ulong :param numberOfBytes...
[ "Read", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L264-L293
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.findFilesWithPattern
def findFilesWithPattern( self, fileName, searchPattern, fillFindData, dokanFileInfo ): """Find files in a certain path that match the search pattern. :param fileName: path to search :type fileName: ctypes.c_wchar_p :param searchPattern: pattern to search for :type s...
python
def findFilesWithPattern( self, fileName, searchPattern, fillFindData, dokanFileInfo ): """Find files in a certain path that match the search pattern. :param fileName: path to search :type fileName: ctypes.c_wchar_p :param searchPattern: pattern to search for :type s...
[ "def", "findFilesWithPattern", "(", "self", ",", "fileName", ",", "searchPattern", ",", "fillFindData", ",", "dokanFileInfo", ")", ":", "try", ":", "ret", "=", "self", ".", "operations", "(", "'findFilesWithPattern'", ",", "fileName", ",", "searchPattern", ")", ...
Find files in a certain path that match the search pattern. :param fileName: path to search :type fileName: ctypes.c_wchar_p :param searchPattern: pattern to search for :type searchPattern: ctypes.c_wchar_p :param fillFindData: function pointer for populating search results ...
[ "Find", "files", "in", "a", "certain", "path", "that", "match", "the", "search", "pattern", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L367-L413
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.setFileTime
def setFileTime( self, fileName, creationTime, lastAccessTime, lastWriteTime, dokanFileInfo ): """Set time values for a file. :param fileName: name of file to set time values for :type fileName: ctypes.c_wchar_p :param creationTime: creation time of file :type creati...
python
def setFileTime( self, fileName, creationTime, lastAccessTime, lastWriteTime, dokanFileInfo ): """Set time values for a file. :param fileName: name of file to set time values for :type fileName: ctypes.c_wchar_p :param creationTime: creation time of file :type creati...
[ "def", "setFileTime", "(", "self", ",", "fileName", ",", "creationTime", ",", "lastAccessTime", ",", "lastWriteTime", ",", "dokanFileInfo", ")", ":", "return", "self", ".", "operations", "(", "'setFileTime'", ",", "fileName", ")" ]
Set time values for a file. :param fileName: name of file to set time values for :type fileName: ctypes.c_wchar_p :param creationTime: creation time of file :type creationTime: ctypes.POINTER(ctypes.wintypes.FILETIME) :param lastAccessTime: last access time of file :type...
[ "Set", "time", "values", "for", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L430-L449
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.moveFile
def moveFile(self, existingFileName, newFileName, replaceExisiting, dokanFileInfo): """Move a file. :param existingFileName: name of file to move :type existingFileName: ctypes.c_wchar_p :param newFileName: new name of file :type newFileName: ctypes.c_wchar_p :param repl...
python
def moveFile(self, existingFileName, newFileName, replaceExisiting, dokanFileInfo): """Move a file. :param existingFileName: name of file to move :type existingFileName: ctypes.c_wchar_p :param newFileName: new name of file :type newFileName: ctypes.c_wchar_p :param repl...
[ "def", "moveFile", "(", "self", ",", "existingFileName", ",", "newFileName", ",", "replaceExisiting", ",", "dokanFileInfo", ")", ":", "return", "self", ".", "operations", "(", "'moveFile'", ",", "existingFileName", ",", "newFileName", ")" ]
Move a file. :param existingFileName: name of file to move :type existingFileName: ctypes.c_wchar_p :param newFileName: new name of file :type newFileName: ctypes.c_wchar_p :param replaceExisting: flag to indicate replacement of existing file :type replaceExisting: ctype...
[ "Move", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L477-L492
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.lockFile
def lockFile(self, fileName, byteOffset, length, dokanFileInfo): """Lock a file. :param fileName: name of file to lock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start lock :type byteOffset: ctypes.c_longlong :param length: number of bytes to lock ...
python
def lockFile(self, fileName, byteOffset, length, dokanFileInfo): """Lock a file. :param fileName: name of file to lock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start lock :type byteOffset: ctypes.c_longlong :param length: number of bytes to lock ...
[ "def", "lockFile", "(", "self", ",", "fileName", ",", "byteOffset", ",", "length", ",", "dokanFileInfo", ")", ":", "return", "self", ".", "operations", "(", "'lockFile'", ",", "fileName", ",", "byteOffset", ",", "length", ")" ]
Lock a file. :param fileName: name of file to lock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start lock :type byteOffset: ctypes.c_longlong :param length: number of bytes to lock :type length: ctypes.c_longlong :param dokanFileInfo: used by ...
[ "Lock", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L524-L539
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.unlockFile
def unlockFile(self, fileName, byteOffset, length, dokanFileInfo): """Unlock a file. :param fileName: name of file to unlock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start unlock :type byteOffset: ctypes.c_longlong :param length: number of bytes to...
python
def unlockFile(self, fileName, byteOffset, length, dokanFileInfo): """Unlock a file. :param fileName: name of file to unlock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start unlock :type byteOffset: ctypes.c_longlong :param length: number of bytes to...
[ "def", "unlockFile", "(", "self", ",", "fileName", ",", "byteOffset", ",", "length", ",", "dokanFileInfo", ")", ":", "return", "self", ".", "operations", "(", "'unlockFile'", ",", "fileName", ",", "byteOffset", ",", "length", ")" ]
Unlock a file. :param fileName: name of file to unlock :type fileName: ctypes.c_wchar_p :param byteOffset: location to start unlock :type byteOffset: ctypes.c_longlong :param length: number of bytes to unlock :type length: ctypes.c_longlong :param dokanFileInfo: ...
[ "Unlock", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L541-L556
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.getDiskFreeSpace
def getDiskFreeSpace( self, freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes, dokanFileInfo, ): """Get the amount of free space on this volume. :param freeBytesAvailable: pointer for free bytes available :type freeBytesAvailable: ctypes....
python
def getDiskFreeSpace( self, freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes, dokanFileInfo, ): """Get the amount of free space on this volume. :param freeBytesAvailable: pointer for free bytes available :type freeBytesAvailable: ctypes....
[ "def", "getDiskFreeSpace", "(", "self", ",", "freeBytesAvailable", ",", "totalNumberOfBytes", ",", "totalNumberOfFreeBytes", ",", "dokanFileInfo", ",", ")", ":", "ret", "=", "self", ".", "operations", "(", "'getDiskFreeSpace'", ")", "ctypes", ".", "memmove", "(", ...
Get the amount of free space on this volume. :param freeBytesAvailable: pointer for free bytes available :type freeBytesAvailable: ctypes.c_void_p :param totalNumberOfBytes: pointer for total number of bytes :type totalNumberOfBytes: ctypes.c_void_p :param totalNumberOfFreeBytes...
[ "Get", "the", "amount", "of", "free", "space", "on", "this", "volume", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L558-L595
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.getVolumeInformation
def getVolumeInformation( self, volumeNameBuffer, volumeNameSize, volumeSerialNumber, maximumComponentLength, fileSystemFlags, fileSystemNameBuffer, fileSystemNameSize, dokanFileInfo, ): """Get information about the volume. :pa...
python
def getVolumeInformation( self, volumeNameBuffer, volumeNameSize, volumeSerialNumber, maximumComponentLength, fileSystemFlags, fileSystemNameBuffer, fileSystemNameSize, dokanFileInfo, ): """Get information about the volume. :pa...
[ "def", "getVolumeInformation", "(", "self", ",", "volumeNameBuffer", ",", "volumeNameSize", ",", "volumeSerialNumber", ",", "maximumComponentLength", ",", "fileSystemFlags", ",", "fileSystemNameBuffer", ",", "fileSystemNameSize", ",", "dokanFileInfo", ",", ")", ":", "re...
Get information about the volume. :param volumeNameBuffer: buffer for volume name :type volumeNameBuffer: ctypes.c_void_p :param volumeNameSize: volume name buffer size :type volumeNameSize: ctypes.c_ulong :param volumeSerialNumber: buffer for volume serial number :type ...
[ "Get", "information", "about", "the", "volume", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L597-L666
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.getFileSecurity
def getFileSecurity( self, fileName, securityInformation, securityDescriptor, lengthSecurityDescriptorBuffer, lengthNeeded, dokanFileInfo, ): """Get security attributes of a file. :param fileName: name of file to get security for :type...
python
def getFileSecurity( self, fileName, securityInformation, securityDescriptor, lengthSecurityDescriptorBuffer, lengthNeeded, dokanFileInfo, ): """Get security attributes of a file. :param fileName: name of file to get security for :type...
[ "def", "getFileSecurity", "(", "self", ",", "fileName", ",", "securityInformation", ",", "securityDescriptor", ",", "lengthSecurityDescriptorBuffer", ",", "lengthNeeded", ",", "dokanFileInfo", ",", ")", ":", "return", "self", ".", "operations", "(", "'getFileSecurity'...
Get security attributes of a file. :param fileName: name of file to get security for :type fileName: ctypes.c_wchar_p :param securityInformation: buffer for security information :type securityInformation: PSECURITY_INFORMATION :param securityDescriptor: buffer for security descr...
[ "Get", "security", "attributes", "of", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L679-L706
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py
Dokan.setFileSecurity
def setFileSecurity( self, fileName, securityInformation, securityDescriptor, lengthSecurityDescriptorBuffer, dokanFileInfo, ): """Set security attributes of a file. :param fileName: name of file to set security for :type fileName: ctypes.c_wc...
python
def setFileSecurity( self, fileName, securityInformation, securityDescriptor, lengthSecurityDescriptorBuffer, dokanFileInfo, ): """Set security attributes of a file. :param fileName: name of file to set security for :type fileName: ctypes.c_wc...
[ "def", "setFileSecurity", "(", "self", ",", "fileName", ",", "securityInformation", ",", "securityDescriptor", ",", "lengthSecurityDescriptorBuffer", ",", "dokanFileInfo", ",", ")", ":", "return", "self", ".", "operations", "(", "'setFileSecurity'", ",", "fileName", ...
Set security attributes of a file. :param fileName: name of file to set security for :type fileName: ctypes.c_wchar_p :param securityInformation: new security information :type securityInformation: PSECURITY_INFORMATION :param securityDescriptor: newsecurity descriptor :...
[ "Set", "security", "attributes", "of", "a", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L708-L732
DataONEorg/d1_python
utilities/src/d1_util/generate_data_package_from_stream.py
createSimpleResourceMap
def createSimpleResourceMap(ore_pid, sci_meta_pid, data_pids): """Create a simple resource map with one metadata document and n data objects.""" ore = ResourceMap() ore.initialize(ore_pid) ore.addMetadataDocument(sci_meta_pid) ore.addDataDocuments(data_pids, sci_meta_pid) return ore
python
def createSimpleResourceMap(ore_pid, sci_meta_pid, data_pids): """Create a simple resource map with one metadata document and n data objects.""" ore = ResourceMap() ore.initialize(ore_pid) ore.addMetadataDocument(sci_meta_pid) ore.addDataDocuments(data_pids, sci_meta_pid) return ore
[ "def", "createSimpleResourceMap", "(", "ore_pid", ",", "sci_meta_pid", ",", "data_pids", ")", ":", "ore", "=", "ResourceMap", "(", ")", "ore", ".", "initialize", "(", "ore_pid", ")", "ore", ".", "addMetadataDocument", "(", "sci_meta_pid", ")", "ore", ".", "a...
Create a simple resource map with one metadata document and n data objects.
[ "Create", "a", "simple", "resource", "map", "with", "one", "metadata", "document", "and", "n", "data", "objects", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/generate_data_package_from_stream.py#L64-L70
DataONEorg/d1_python
utilities/src/d1_util/generate_data_package_from_stream.py
pids2ore
def pids2ore(in_stream, fmt='xml', base_url='https://cn.dataone.org/cn'): """read pids from in_stream and generate a resource map. first pid is the ore_pid second is the sci meta pid remainder are data pids """ pids = [] for line in in_stream: pid = line.strip() if len(pid) > 0: ...
python
def pids2ore(in_stream, fmt='xml', base_url='https://cn.dataone.org/cn'): """read pids from in_stream and generate a resource map. first pid is the ore_pid second is the sci meta pid remainder are data pids """ pids = [] for line in in_stream: pid = line.strip() if len(pid) > 0: ...
[ "def", "pids2ore", "(", "in_stream", ",", "fmt", "=", "'xml'", ",", "base_url", "=", "'https://cn.dataone.org/cn'", ")", ":", "pids", "=", "[", "]", "for", "line", "in", "in_stream", ":", "pid", "=", "line", ".", "strip", "(", ")", "if", "len", "(", ...
read pids from in_stream and generate a resource map. first pid is the ore_pid second is the sci meta pid remainder are data pids
[ "read", "pids", "from", "in_stream", "and", "generate", "a", "resource", "map", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/generate_data_package_from_stream.py#L73-L99
genialis/resolwe
resolwe/flow/managers/workload_connectors/celery.py
Connector.submit
def submit(self, data, runtime_dir, argv): """Run process. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`. """ queue = 'ordinary' if data.process.scheduling_class == Process.SCHEDULING_CLASS_INTERACTIVE: queue = ...
python
def submit(self, data, runtime_dir, argv): """Run process. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`. """ queue = 'ordinary' if data.process.scheduling_class == Process.SCHEDULING_CLASS_INTERACTIVE: queue = ...
[ "def", "submit", "(", "self", ",", "data", ",", "runtime_dir", ",", "argv", ")", ":", "queue", "=", "'ordinary'", "if", "data", ".", "process", ".", "scheduling_class", "==", "Process", ".", "SCHEDULING_CLASS_INTERACTIVE", ":", "queue", "=", "'hipri'", "logg...
Run process. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`.
[ "Run", "process", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/workload_connectors/celery.py#L35-L53
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/object_tree.py
ObjectTree.refresh
def refresh(self): """Synchronize the local tree of Solr records for DataONE identifiers and queries with the reference tree.""" if self._source_tree.cache_is_stale(): self._source_tree.refresh() logging.info('Refreshing object tree') self._init_cache() ...
python
def refresh(self): """Synchronize the local tree of Solr records for DataONE identifiers and queries with the reference tree.""" if self._source_tree.cache_is_stale(): self._source_tree.refresh() logging.info('Refreshing object tree') self._init_cache() ...
[ "def", "refresh", "(", "self", ")", ":", "if", "self", ".", "_source_tree", ".", "cache_is_stale", "(", ")", ":", "self", ".", "_source_tree", ".", "refresh", "(", ")", "logging", ".", "info", "(", "'Refreshing object tree'", ")", "self", ".", "_init_cache...
Synchronize the local tree of Solr records for DataONE identifiers and queries with the reference tree.
[ "Synchronize", "the", "local", "tree", "of", "Solr", "records", "for", "DataONE", "identifiers", "and", "queries", "with", "the", "reference", "tree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/object_tree.py#L56-L63
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/object_tree.py
ObjectTree.get_object_record
def get_object_record(self, pid): """Get an object that has already been cached in the object tree. Caching happens when the object tree is refreshed. """ try: return self._cache['records'][pid] except KeyError: raise d1_onedrive.impl.onedrive_exceptions...
python
def get_object_record(self, pid): """Get an object that has already been cached in the object tree. Caching happens when the object tree is refreshed. """ try: return self._cache['records'][pid] except KeyError: raise d1_onedrive.impl.onedrive_exceptions...
[ "def", "get_object_record", "(", "self", ",", "pid", ")", ":", "try", ":", "return", "self", ".", "_cache", "[", "'records'", "]", "[", "pid", "]", "except", "KeyError", ":", "raise", "d1_onedrive", ".", "impl", ".", "onedrive_exceptions", ".", "ONEDriveEx...
Get an object that has already been cached in the object tree. Caching happens when the object tree is refreshed.
[ "Get", "an", "object", "that", "has", "already", "been", "cached", "in", "the", "object", "tree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/object_tree.py#L72-L81
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/object_tree.py
ObjectTree.get_object_record_with_sync
def get_object_record_with_sync(self, pid): """Get an object that may not currently be in the cache. If the object is not in the cache, an attempt is made to retrieve the record from a CN on the fly. If the object is found, it is cached before being returned to the user. This allows the...
python
def get_object_record_with_sync(self, pid): """Get an object that may not currently be in the cache. If the object is not in the cache, an attempt is made to retrieve the record from a CN on the fly. If the object is found, it is cached before being returned to the user. This allows the...
[ "def", "get_object_record_with_sync", "(", "self", ",", "pid", ")", ":", "try", ":", "return", "self", ".", "_cache", "[", "'records'", "]", "[", "pid", "]", "except", "KeyError", ":", "return", "self", ".", "_get_uncached_object_record", "(", "pid", ")" ]
Get an object that may not currently be in the cache. If the object is not in the cache, an attempt is made to retrieve the record from a CN on the fly. If the object is found, it is cached before being returned to the user. This allows the object tree caching system to be used for objects ...
[ "Get", "an", "object", "that", "may", "not", "currently", "be", "in", "the", "cache", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/object_tree.py#L83-L96
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/object_tree.py
ObjectTree._create_cache_item_for_pid
def _create_cache_item_for_pid(self, cache_folder, pid): """The source tree can contain identifiers that are no longer valid (or were never valid). Any items for which a Solr record cannot be retrieved are silently skipped. """ try: record = self._solr_client.get_so...
python
def _create_cache_item_for_pid(self, cache_folder, pid): """The source tree can contain identifiers that are no longer valid (or were never valid). Any items for which a Solr record cannot be retrieved are silently skipped. """ try: record = self._solr_client.get_so...
[ "def", "_create_cache_item_for_pid", "(", "self", ",", "cache_folder", ",", "pid", ")", ":", "try", ":", "record", "=", "self", ".", "_solr_client", ".", "get_solr_record", "(", "pid", ")", "except", "d1_onedrive", ".", "impl", ".", "onedrive_exceptions", ".",...
The source tree can contain identifiers that are no longer valid (or were never valid). Any items for which a Solr record cannot be retrieved are silently skipped.
[ "The", "source", "tree", "can", "contain", "identifiers", "that", "are", "no", "longer", "valid", "(", "or", "were", "never", "valid", ")", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/object_tree.py#L177-L189
genialis/resolwe
resolwe/flow/managers/dispatcher.py
dependency_status
def dependency_status(data): """Return abstracted status of dependencies. - ``STATUS_ERROR`` .. one dependency has error status or was deleted - ``STATUS_DONE`` .. all dependencies have done status - ``None`` .. other """ parents_statuses = set( DataDependency.objects.filter( ...
python
def dependency_status(data): """Return abstracted status of dependencies. - ``STATUS_ERROR`` .. one dependency has error status or was deleted - ``STATUS_DONE`` .. all dependencies have done status - ``None`` .. other """ parents_statuses = set( DataDependency.objects.filter( ...
[ "def", "dependency_status", "(", "data", ")", ":", "parents_statuses", "=", "set", "(", "DataDependency", ".", "objects", ".", "filter", "(", "child", "=", "data", ",", "kind", "=", "DataDependency", ".", "KIND_IO", ")", ".", "distinct", "(", "'parent__statu...
Return abstracted status of dependencies. - ``STATUS_ERROR`` .. one dependency has error status or was deleted - ``STATUS_DONE`` .. all dependencies have done status - ``None`` .. other
[ "Return", "abstracted", "status", "of", "dependencies", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L60-L87
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.discover_engines
def discover_engines(self, executor=None): """Discover configured engines. :param executor: Optional executor module override """ if executor is None: executor = getattr(settings, 'FLOW_EXECUTOR', {}).get('NAME', 'resolwe.flow.executors.local') self.executor = self.l...
python
def discover_engines(self, executor=None): """Discover configured engines. :param executor: Optional executor module override """ if executor is None: executor = getattr(settings, 'FLOW_EXECUTOR', {}).get('NAME', 'resolwe.flow.executors.local') self.executor = self.l...
[ "def", "discover_engines", "(", "self", ",", "executor", "=", "None", ")", ":", "if", "executor", "is", "None", ":", "executor", "=", "getattr", "(", "settings", ",", "'FLOW_EXECUTOR'", ",", "{", "}", ")", ".", "get", "(", "'NAME'", ",", "'resolwe.flow.e...
Discover configured engines. :param executor: Optional executor module override
[ "Discover", "configured", "engines", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L230-L252
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.reset
def reset(self, keep_state=False): """Reset the shared state and drain Django Channels. :param keep_state: If ``True``, do not reset the shared manager state (useful in tests, where the settings overrides need to be kept). Defaults to ``False``. """ if not keep_s...
python
def reset(self, keep_state=False): """Reset the shared state and drain Django Channels. :param keep_state: If ``True``, do not reset the shared manager state (useful in tests, where the settings overrides need to be kept). Defaults to ``False``. """ if not keep_s...
[ "def", "reset", "(", "self", ",", "keep_state", "=", "False", ")", ":", "if", "not", "keep_state", ":", "self", ".", "state", "=", "state", ".", "ManagerState", "(", "state", ".", "MANAGER_STATE_PREFIX", ")", "self", ".", "state", ".", "reset", "(", ")...
Reset the shared state and drain Django Channels. :param keep_state: If ``True``, do not reset the shared manager state (useful in tests, where the settings overrides need to be kept). Defaults to ``False``.
[ "Reset", "the", "shared", "state", "and", "drain", "Django", "Channels", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L254-L265
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._marshal_settings
def _marshal_settings(self): """Marshal Django settings into a serializable object. :return: The serialized settings. :rtype: dict """ result = {} for key in dir(settings): if any(map(key.startswith, ['FLOW_', 'RESOLWE_', 'CELERY_'])): result[...
python
def _marshal_settings(self): """Marshal Django settings into a serializable object. :return: The serialized settings. :rtype: dict """ result = {} for key in dir(settings): if any(map(key.startswith, ['FLOW_', 'RESOLWE_', 'CELERY_'])): result[...
[ "def", "_marshal_settings", "(", "self", ")", ":", "result", "=", "{", "}", "for", "key", "in", "dir", "(", "settings", ")", ":", "if", "any", "(", "map", "(", "key", ".", "startswith", ",", "[", "'FLOW_'", ",", "'RESOLWE_'", ",", "'CELERY_'", "]", ...
Marshal Django settings into a serializable object. :return: The serialized settings. :rtype: dict
[ "Marshal", "Django", "settings", "into", "a", "serializable", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L343-L353
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._include_environment_variables
def _include_environment_variables(self, program, executor_vars): """Define environment variables.""" env_vars = { 'RESOLWE_HOST_URL': self.settings_actual.get('RESOLWE_HOST_URL', 'localhost'), } set_env = self.settings_actual.get('FLOW_EXECUTOR', {}).get('SET_ENV', {}) ...
python
def _include_environment_variables(self, program, executor_vars): """Define environment variables.""" env_vars = { 'RESOLWE_HOST_URL': self.settings_actual.get('RESOLWE_HOST_URL', 'localhost'), } set_env = self.settings_actual.get('FLOW_EXECUTOR', {}).get('SET_ENV', {}) ...
[ "def", "_include_environment_variables", "(", "self", ",", "program", ",", "executor_vars", ")", ":", "env_vars", "=", "{", "'RESOLWE_HOST_URL'", ":", "self", ".", "settings_actual", ".", "get", "(", "'RESOLWE_HOST_URL'", ",", "'localhost'", ")", ",", "}", "set_...
Define environment variables.
[ "Define", "environment", "variables", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L355-L366
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.run
def run(self, data, runtime_dir, argv): """Select a concrete connector and run the process through it. :param data: The :class:`~resolwe.flow.models.Data` object that is to be run. :param runtime_dir: The directory the executor is run from. :param argv: The argument vector u...
python
def run(self, data, runtime_dir, argv): """Select a concrete connector and run the process through it. :param data: The :class:`~resolwe.flow.models.Data` object that is to be run. :param runtime_dir: The directory the executor is run from. :param argv: The argument vector u...
[ "def", "run", "(", "self", ",", "data", ",", "runtime_dir", ",", "argv", ")", ":", "process_scheduling", "=", "self", ".", "scheduling_class_map", "[", "data", ".", "process", ".", "scheduling_class", "]", "if", "'DISPATCHER_MAPPING'", "in", "getattr", "(", ...
Select a concrete connector and run the process through it. :param data: The :class:`~resolwe.flow.models.Data` object that is to be run. :param runtime_dir: The directory the executor is run from. :param argv: The argument vector used to spawn the executor.
[ "Select", "a", "concrete", "connector", "and", "run", "the", "process", "through", "it", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L368-L386
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._get_per_data_dir
def _get_per_data_dir(self, dir_base, subpath): """Extend the given base directory with a per-data component. The method creates a private path for the :class:`~resolwe.flow.models.Data` object, such as:: ./test_data/1/ if ``base_dir`` is ``'./test_data'`` and ``subpath`` ...
python
def _get_per_data_dir(self, dir_base, subpath): """Extend the given base directory with a per-data component. The method creates a private path for the :class:`~resolwe.flow.models.Data` object, such as:: ./test_data/1/ if ``base_dir`` is ``'./test_data'`` and ``subpath`` ...
[ "def", "_get_per_data_dir", "(", "self", ",", "dir_base", ",", "subpath", ")", ":", "# Use Django settings here, because the state must be preserved", "# across events. This also implies the directory settings can't", "# be patched outside the manager and then just sent along in the", "# c...
Extend the given base directory with a per-data component. The method creates a private path for the :class:`~resolwe.flow.models.Data` object, such as:: ./test_data/1/ if ``base_dir`` is ``'./test_data'`` and ``subpath`` is ``1``. :param dir_base: The base path to be ext...
[ "Extend", "the", "given", "base", "directory", "with", "a", "per", "-", "data", "component", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L388-L411
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._prepare_data_dir
def _prepare_data_dir(self, data): """Prepare destination directory where the data will live. :param data: The :class:`~resolwe.flow.models.Data` object for which to prepare the private execution directory. :return: The prepared data directory path. :rtype: str """ ...
python
def _prepare_data_dir(self, data): """Prepare destination directory where the data will live. :param data: The :class:`~resolwe.flow.models.Data` object for which to prepare the private execution directory. :return: The prepared data directory path. :rtype: str """ ...
[ "def", "_prepare_data_dir", "(", "self", ",", "data", ")", ":", "logger", ".", "debug", "(", "__", "(", "\"Preparing data directory for Data with id {}.\"", ",", "data", ".", "id", ")", ")", "with", "transaction", ".", "atomic", "(", ")", ":", "# Create a temp...
Prepare destination directory where the data will live. :param data: The :class:`~resolwe.flow.models.Data` object for which to prepare the private execution directory. :return: The prepared data directory path. :rtype: str
[ "Prepare", "destination", "directory", "where", "the", "data", "will", "live", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L413-L438
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._prepare_context
def _prepare_context(self, data_id, data_dir, runtime_dir, **kwargs): """Prepare settings and constants JSONs for the executor. Settings and constants provided by other ``resolwe`` modules and :class:`~django.conf.settings` are all inaccessible in the executor once it is deployed, so th...
python
def _prepare_context(self, data_id, data_dir, runtime_dir, **kwargs): """Prepare settings and constants JSONs for the executor. Settings and constants provided by other ``resolwe`` modules and :class:`~django.conf.settings` are all inaccessible in the executor once it is deployed, so th...
[ "def", "_prepare_context", "(", "self", ",", "data_id", ",", "data_dir", ",", "runtime_dir", ",", "*", "*", "kwargs", ")", ":", "files", "=", "{", "}", "secrets", "=", "{", "}", "settings_dict", "=", "{", "}", "settings_dict", "[", "'DATA_DIR'", "]", "...
Prepare settings and constants JSONs for the executor. Settings and constants provided by other ``resolwe`` modules and :class:`~django.conf.settings` are all inaccessible in the executor once it is deployed, so they need to be serialized into the runtime directory. :param data...
[ "Prepare", "settings", "and", "constants", "JSONs", "for", "the", "executor", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L440-L510
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._prepare_executor
def _prepare_executor(self, data, executor): """Copy executor sources into the destination directory. :param data: The :class:`~resolwe.flow.models.Data` object being prepared for. :param executor: The fully qualified name of the executor that is to be used for this data...
python
def _prepare_executor(self, data, executor): """Copy executor sources into the destination directory. :param data: The :class:`~resolwe.flow.models.Data` object being prepared for. :param executor: The fully qualified name of the executor that is to be used for this data...
[ "def", "_prepare_executor", "(", "self", ",", "data", ",", "executor", ")", ":", "logger", ".", "debug", "(", "__", "(", "\"Preparing executor for Data with id {}\"", ",", "data", ".", "id", ")", ")", "# Both of these imports are here only to get the packages' paths.", ...
Copy executor sources into the destination directory. :param data: The :class:`~resolwe.flow.models.Data` object being prepared for. :param executor: The fully qualified name of the executor that is to be used for this data object. :return: Tuple containing the relative ...
[ "Copy", "executor", "sources", "into", "the", "destination", "directory", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L512-L538
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._prepare_script
def _prepare_script(self, dest_dir, program): """Copy the script into the destination directory. :param dest_dir: The target directory where the script will be saved. :param program: The script text to be saved. :return: The name of the script file. :rtype: str ...
python
def _prepare_script(self, dest_dir, program): """Copy the script into the destination directory. :param dest_dir: The target directory where the script will be saved. :param program: The script text to be saved. :return: The name of the script file. :rtype: str ...
[ "def", "_prepare_script", "(", "self", ",", "dest_dir", ",", "program", ")", ":", "script_name", "=", "ExecutorFiles", ".", "PROCESS_SCRIPT", "dest_file", "=", "os", ".", "path", ".", "join", "(", "dest_dir", ",", "script_name", ")", "with", "open", "(", "...
Copy the script into the destination directory. :param dest_dir: The target directory where the script will be saved. :param program: The script text to be saved. :return: The name of the script file. :rtype: str
[ "Copy", "the", "script", "into", "the", "destination", "directory", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L540-L554
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.handle_control_event
async def handle_control_event(self, message): """Handle an event from the Channels layer. Channels layer callback, do not call directly. """ cmd = message[WorkerProtocol.COMMAND] logger.debug(__("Manager worker got channel command '{}'.", cmd)) # Prepare settings for u...
python
async def handle_control_event(self, message): """Handle an event from the Channels layer. Channels layer callback, do not call directly. """ cmd = message[WorkerProtocol.COMMAND] logger.debug(__("Manager worker got channel command '{}'.", cmd)) # Prepare settings for u...
[ "async", "def", "handle_control_event", "(", "self", ",", "message", ")", ":", "cmd", "=", "message", "[", "WorkerProtocol", ".", "COMMAND", "]", "logger", ".", "debug", "(", "__", "(", "\"Manager worker got channel command '{}'.\"", ",", "cmd", ")", ")", "# P...
Handle an event from the Channels layer. Channels layer callback, do not call directly.
[ "Handle", "an", "event", "from", "the", "Channels", "layer", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L564-L629
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._ensure_counter
def _ensure_counter(self): """Ensure the sync counter is a valid non-dummy object.""" if not isinstance(self.sync_counter, self._SynchronizationManager): self.sync_counter = self._SynchronizationManager()
python
def _ensure_counter(self): """Ensure the sync counter is a valid non-dummy object.""" if not isinstance(self.sync_counter, self._SynchronizationManager): self.sync_counter = self._SynchronizationManager()
[ "def", "_ensure_counter", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "sync_counter", ",", "self", ".", "_SynchronizationManager", ")", ":", "self", ".", "sync_counter", "=", "self", ".", "_SynchronizationManager", "(", ")" ]
Ensure the sync counter is a valid non-dummy object.
[ "Ensure", "the", "sync", "counter", "is", "a", "valid", "non", "-", "dummy", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L631-L634
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.execution_barrier
async def execution_barrier(self): """Wait for executors to finish. At least one must finish after this point to avoid a deadlock. """ async def _barrier(): """Enter the sync block and exit the app afterwards.""" async with self.sync_counter: pass...
python
async def execution_barrier(self): """Wait for executors to finish. At least one must finish after this point to avoid a deadlock. """ async def _barrier(): """Enter the sync block and exit the app afterwards.""" async with self.sync_counter: pass...
[ "async", "def", "execution_barrier", "(", "self", ")", ":", "async", "def", "_barrier", "(", ")", ":", "\"\"\"Enter the sync block and exit the app afterwards.\"\"\"", "async", "with", "self", ".", "sync_counter", ":", "pass", "await", "consumer", ".", "exit_consumer"...
Wait for executors to finish. At least one must finish after this point to avoid a deadlock.
[ "Wait", "for", "executors", "to", "finish", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L636-L652
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.communicate
async def communicate(self, data_id=None, run_sync=False, save_settings=True): """Scan database for resolving Data objects and process them. This is submitted as a task to the manager's channel workers. :param data_id: Optional id of Data object which (+ its children) should be pro...
python
async def communicate(self, data_id=None, run_sync=False, save_settings=True): """Scan database for resolving Data objects and process them. This is submitted as a task to the manager's channel workers. :param data_id: Optional id of Data object which (+ its children) should be pro...
[ "async", "def", "communicate", "(", "self", ",", "data_id", "=", "None", ",", "run_sync", "=", "False", ",", "save_settings", "=", "True", ")", ":", "executor", "=", "getattr", "(", "settings", ",", "'FLOW_EXECUTOR'", ",", "{", "}", ")", ".", "get", "(...
Scan database for resolving Data objects and process them. This is submitted as a task to the manager's channel workers. :param data_id: Optional id of Data object which (+ its children) should be processes. If it is not given, all resolving objects are processed. :para...
[ "Scan", "database", "for", "resolving", "Data", "objects", "and", "process", "them", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L654-L711
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._data_execute
def _data_execute(self, data, program, executor): """Execute the Data object. The activities carried out here include target directory preparation, executor copying, setting serialization and actual execution of the object. :param data: The :class:`~resolwe.flow.models.Data` ob...
python
def _data_execute(self, data, program, executor): """Execute the Data object. The activities carried out here include target directory preparation, executor copying, setting serialization and actual execution of the object. :param data: The :class:`~resolwe.flow.models.Data` ob...
[ "def", "_data_execute", "(", "self", ",", "data", ",", "program", ",", "executor", ")", ":", "if", "not", "program", ":", "return", "logger", ".", "debug", "(", "__", "(", "\"Manager preparing Data with id {} for processing.\"", ",", "data", ".", "id", ")", ...
Execute the Data object. The activities carried out here include target directory preparation, executor copying, setting serialization and actual execution of the object. :param data: The :class:`~resolwe.flow.models.Data` object to execute. :param program: The proc...
[ "Execute", "the", "Data", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L713-L765
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager._data_scan
def _data_scan(self, data_id=None, executor='resolwe.flow.executors.local', **kwargs): """Scan for new Data objects and execute them. :param data_id: Optional id of Data object which (+ its children) should be scanned. If it is not given, all resolving objects are processed. ...
python
def _data_scan(self, data_id=None, executor='resolwe.flow.executors.local', **kwargs): """Scan for new Data objects and execute them. :param data_id: Optional id of Data object which (+ its children) should be scanned. If it is not given, all resolving objects are processed. ...
[ "def", "_data_scan", "(", "self", ",", "data_id", "=", "None", ",", "executor", "=", "'resolwe.flow.executors.local'", ",", "*", "*", "kwargs", ")", ":", "def", "process_data_object", "(", "data", ")", ":", "\"\"\"Process a single data object.\"\"\"", "# Lock for up...
Scan for new Data objects and execute them. :param data_id: Optional id of Data object which (+ its children) should be scanned. If it is not given, all resolving objects are processed. :param executor: The fully qualified name of the executor to use for all :class:`...
[ "Scan", "for", "new", "Data", "objects", "and", "execute", "them", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L767-L910
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.get_expression_engine
def get_expression_engine(self, name): """Return an expression engine instance.""" try: return self.expression_engines[name] except KeyError: raise InvalidEngineError("Unsupported expression engine: {}".format(name))
python
def get_expression_engine(self, name): """Return an expression engine instance.""" try: return self.expression_engines[name] except KeyError: raise InvalidEngineError("Unsupported expression engine: {}".format(name))
[ "def", "get_expression_engine", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "expression_engines", "[", "name", "]", "except", "KeyError", ":", "raise", "InvalidEngineError", "(", "\"Unsupported expression engine: {}\"", ".", "format", "(...
Return an expression engine instance.
[ "Return", "an", "expression", "engine", "instance", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L916-L921
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.get_execution_engine
def get_execution_engine(self, name): """Return an execution engine instance.""" try: return self.execution_engines[name] except KeyError: raise InvalidEngineError("Unsupported execution engine: {}".format(name))
python
def get_execution_engine(self, name): """Return an execution engine instance.""" try: return self.execution_engines[name] except KeyError: raise InvalidEngineError("Unsupported execution engine: {}".format(name))
[ "def", "get_execution_engine", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "execution_engines", "[", "name", "]", "except", "KeyError", ":", "raise", "InvalidEngineError", "(", "\"Unsupported execution engine: {}\"", ".", "format", "(", ...
Return an execution engine instance.
[ "Return", "an", "execution", "engine", "instance", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L923-L928
genialis/resolwe
resolwe/flow/managers/dispatcher.py
Manager.load_executor
def load_executor(self, executor_name): """Load process executor.""" executor_name = executor_name + '.prepare' module = import_module(executor_name) return module.FlowExecutorPreparer()
python
def load_executor(self, executor_name): """Load process executor.""" executor_name = executor_name + '.prepare' module = import_module(executor_name) return module.FlowExecutorPreparer()
[ "def", "load_executor", "(", "self", ",", "executor_name", ")", ":", "executor_name", "=", "executor_name", "+", "'.prepare'", "module", "=", "import_module", "(", "executor_name", ")", "return", "module", ".", "FlowExecutorPreparer", "(", ")" ]
Load process executor.
[ "Load", "process", "executor", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L930-L934
DataONEorg/d1_python
lib_common/src/d1_common/cert/subjects.py
extract_subjects
def extract_subjects(cert_pem): """Extract subjects from a DataONE PEM (Base64) encoded X.509 v3 certificate. Args: cert_pem: str or bytes PEM (Base64) encoded X.509 v3 certificate Returns: 2-tuple: - The primary subject string, extracted from the certificate DN. - A se...
python
def extract_subjects(cert_pem): """Extract subjects from a DataONE PEM (Base64) encoded X.509 v3 certificate. Args: cert_pem: str or bytes PEM (Base64) encoded X.509 v3 certificate Returns: 2-tuple: - The primary subject string, extracted from the certificate DN. - A se...
[ "def", "extract_subjects", "(", "cert_pem", ")", ":", "primary_str", ",", "subject_info_xml", "=", "d1_common", ".", "cert", ".", "x509", ".", "extract_subjects", "(", "cert_pem", ")", "equivalent_set", "=", "{", "primary_str", ",", "d1_common", ".", "const", ...
Extract subjects from a DataONE PEM (Base64) encoded X.509 v3 certificate. Args: cert_pem: str or bytes PEM (Base64) encoded X.509 v3 certificate Returns: 2-tuple: - The primary subject string, extracted from the certificate DN. - A set of equivalent identities, group membe...
[ "Extract", "subjects", "from", "a", "DataONE", "PEM", "(", "Base64", ")", "encoded", "X", ".", "509", "v3", "certificate", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subjects.py#L32-L59
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.get_queryset
def get_queryset(self): # pylint: disable=method-hidden """Return queryset.""" if self.request and self.request.query_params.get('hydrate_data', False): return self.queryset.prefetch_related('data__entity_set') return self.queryset
python
def get_queryset(self): # pylint: disable=method-hidden """Return queryset.""" if self.request and self.request.query_params.get('hydrate_data', False): return self.queryset.prefetch_related('data__entity_set') return self.queryset
[ "def", "get_queryset", "(", "self", ")", ":", "# pylint: disable=method-hidden", "if", "self", ".", "request", "and", "self", ".", "request", ".", "query_params", ".", "get", "(", "'hydrate_data'", ",", "False", ")", ":", "return", "self", ".", "queryset", "...
Return queryset.
[ "Return", "queryset", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L38-L43
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet._get_collection_for_user
def _get_collection_for_user(self, collection_id, user): """Check that collection exists and user has `add` permission.""" collection_query = Collection.objects.filter(pk=collection_id) if not collection_query.exists(): raise exceptions.ValidationError('Collection id does not exist')...
python
def _get_collection_for_user(self, collection_id, user): """Check that collection exists and user has `add` permission.""" collection_query = Collection.objects.filter(pk=collection_id) if not collection_query.exists(): raise exceptions.ValidationError('Collection id does not exist')...
[ "def", "_get_collection_for_user", "(", "self", ",", "collection_id", ",", "user", ")", ":", "collection_query", "=", "Collection", ".", "objects", ".", "filter", "(", "pk", "=", "collection_id", ")", "if", "not", "collection_query", ".", "exists", "(", ")", ...
Check that collection exists and user has `add` permission.
[ "Check", "that", "collection", "exists", "and", "user", "has", "add", "permission", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L45-L58
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet._get_entities
def _get_entities(self, user, ids): """Return entities queryset based on provided entity ids.""" queryset = get_objects_for_user(user, 'view_entity', Entity.objects.filter(id__in=ids)) actual_ids = queryset.values_list('id', flat=True) missing_ids = list(set(ids) - set(actual_ids)) ...
python
def _get_entities(self, user, ids): """Return entities queryset based on provided entity ids.""" queryset = get_objects_for_user(user, 'view_entity', Entity.objects.filter(id__in=ids)) actual_ids = queryset.values_list('id', flat=True) missing_ids = list(set(ids) - set(actual_ids)) ...
[ "def", "_get_entities", "(", "self", ",", "user", ",", "ids", ")", ":", "queryset", "=", "get_objects_for_user", "(", "user", ",", "'view_entity'", ",", "Entity", ".", "objects", ".", "filter", "(", "id__in", "=", "ids", ")", ")", "actual_ids", "=", "que...
Return entities queryset based on provided entity ids.
[ "Return", "entities", "queryset", "based", "on", "provided", "entity", "ids", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L60-L70
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.set_content_permissions
def set_content_permissions(self, user, obj, payload): """Apply permissions to data objects in ``Entity``.""" # Data doesn't have "ADD" permission, so it has to be removed payload = remove_permission(payload, 'add') for data in obj.data.all(): if user.has_perm('share_data', ...
python
def set_content_permissions(self, user, obj, payload): """Apply permissions to data objects in ``Entity``.""" # Data doesn't have "ADD" permission, so it has to be removed payload = remove_permission(payload, 'add') for data in obj.data.all(): if user.has_perm('share_data', ...
[ "def", "set_content_permissions", "(", "self", ",", "user", ",", "obj", ",", "payload", ")", ":", "# Data doesn't have \"ADD\" permission, so it has to be removed", "payload", "=", "remove_permission", "(", "payload", ",", "'add'", ")", "for", "data", "in", "obj", "...
Apply permissions to data objects in ``Entity``.
[ "Apply", "permissions", "to", "data", "objects", "in", "Entity", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L72-L79
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.destroy
def destroy(self, request, *args, **kwargs): """Destroy a model instance. If ``delete_content`` flag is set in query parameters, also all Data objects contained in entity will be deleted. """ obj = self.get_object() user = request.user if strtobool(request.query...
python
def destroy(self, request, *args, **kwargs): """Destroy a model instance. If ``delete_content`` flag is set in query parameters, also all Data objects contained in entity will be deleted. """ obj = self.get_object() user = request.user if strtobool(request.query...
[ "def", "destroy", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "self", ".", "get_object", "(", ")", "user", "=", "request", ".", "user", "if", "strtobool", "(", "request", ".", "query_params", ".", "...
Destroy a model instance. If ``delete_content`` flag is set in query parameters, also all Data objects contained in entity will be deleted.
[ "Destroy", "a", "model", "instance", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L81-L104
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.add_to_collection
def add_to_collection(self, request, pk=None): """Add Entity to a collection.""" entity = self.get_object() # TODO use `self.get_ids` (and elsewhere). Backwards # incompatible because raised error's response contains # ``detail`` instead of ``error``). if 'ids' not in re...
python
def add_to_collection(self, request, pk=None): """Add Entity to a collection.""" entity = self.get_object() # TODO use `self.get_ids` (and elsewhere). Backwards # incompatible because raised error's response contains # ``detail`` instead of ``error``). if 'ids' not in re...
[ "def", "add_to_collection", "(", "self", ",", "request", ",", "pk", "=", "None", ")", ":", "entity", "=", "self", ".", "get_object", "(", ")", "# TODO use `self.get_ids` (and elsewhere). Backwards", "# incompatible because raised error's response contains", "# ``detail`` in...
Add Entity to a collection.
[ "Add", "Entity", "to", "a", "collection", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L107-L127
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.add_data
def add_data(self, request, pk=None): """Add data to Entity and it's collection.""" # add data to entity resp = super().add_data(request, pk) # add data to collections in which entity is entity = self.get_object() for collection in entity.collections.all(): c...
python
def add_data(self, request, pk=None): """Add data to Entity and it's collection.""" # add data to entity resp = super().add_data(request, pk) # add data to collections in which entity is entity = self.get_object() for collection in entity.collections.all(): c...
[ "def", "add_data", "(", "self", ",", "request", ",", "pk", "=", "None", ")", ":", "# add data to entity", "resp", "=", "super", "(", ")", ".", "add_data", "(", "request", ",", "pk", ")", "# add data to collections in which entity is", "entity", "=", "self", ...
Add data to Entity and it's collection.
[ "Add", "data", "to", "Entity", "and", "it", "s", "collection", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L150-L160
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.move_to_collection
def move_to_collection(self, request, *args, **kwargs): """Move samples from source to destination collection.""" ids = self.get_ids(request.data) src_collection_id = self.get_id(request.data, 'source_collection') dst_collection_id = self.get_id(request.data, 'destination_collection') ...
python
def move_to_collection(self, request, *args, **kwargs): """Move samples from source to destination collection.""" ids = self.get_ids(request.data) src_collection_id = self.get_id(request.data, 'source_collection') dst_collection_id = self.get_id(request.data, 'destination_collection') ...
[ "def", "move_to_collection", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ids", "=", "self", ".", "get_ids", "(", "request", ".", "data", ")", "src_collection_id", "=", "self", ".", "get_id", "(", "request", ".", ...
Move samples from source to destination collection.
[ "Move", "samples", "from", "source", "to", "destination", "collection", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L163-L175
genialis/resolwe
resolwe/flow/views/entity.py
EntityViewSet.update
def update(self, request, *args, **kwargs): """Update an entity. Original queryset produces a temporary database table whose rows cannot be selected for an update. As a workaround, we patch get_queryset function to return only Entity objects without additional data that is not n...
python
def update(self, request, *args, **kwargs): """Update an entity. Original queryset produces a temporary database table whose rows cannot be selected for an update. As a workaround, we patch get_queryset function to return only Entity objects without additional data that is not n...
[ "def", "update", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "orig_get_queryset", "=", "self", ".", "get_queryset", "def", "patched_get_queryset", "(", ")", ":", "\"\"\"Patched get_queryset method.\"\"\"", "entity_ids", "=",...
Update an entity. Original queryset produces a temporary database table whose rows cannot be selected for an update. As a workaround, we patch get_queryset function to return only Entity objects without additional data that is not needed for the update.
[ "Update", "an", "entity", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L180-L198
genialis/resolwe
resolwe/flow/executors/docker/run.py
FlowExecutor.start
async def start(self): """Start process execution.""" # arguments passed to the Docker command command_args = { 'command': self.command, 'container_image': self.requirements.get('image', constants.DEFAULT_CONTAINER_IMAGE), } # Get limit defaults. ...
python
async def start(self): """Start process execution.""" # arguments passed to the Docker command command_args = { 'command': self.command, 'container_image': self.requirements.get('image', constants.DEFAULT_CONTAINER_IMAGE), } # Get limit defaults. ...
[ "async", "def", "start", "(", "self", ")", ":", "# arguments passed to the Docker command", "command_args", "=", "{", "'command'", ":", "self", ".", "command", ",", "'container_image'", ":", "self", ".", "requirements", ".", "get", "(", "'image'", ",", "constant...
Start process execution.
[ "Start", "process", "execution", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/docker/run.py#L52-L300
genialis/resolwe
resolwe/flow/executors/docker/run.py
FlowExecutor.run_script
async def run_script(self, script): """Execute the script and save results.""" # Create a Bash command to add all the tools to PATH. tools_paths = ':'.join([map_["dest"] for map_ in self.tools_volumes]) add_tools_path = 'export PATH=$PATH:{}'.format(tools_paths) # Spawn another c...
python
async def run_script(self, script): """Execute the script and save results.""" # Create a Bash command to add all the tools to PATH. tools_paths = ':'.join([map_["dest"] for map_ in self.tools_volumes]) add_tools_path = 'export PATH=$PATH:{}'.format(tools_paths) # Spawn another c...
[ "async", "def", "run_script", "(", "self", ",", "script", ")", ":", "# Create a Bash command to add all the tools to PATH.", "tools_paths", "=", "':'", ".", "join", "(", "[", "map_", "[", "\"dest\"", "]", "for", "map_", "in", "self", ".", "tools_volumes", "]", ...
Execute the script and save results.
[ "Execute", "the", "script", "and", "save", "results", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/docker/run.py#L302-L316
genialis/resolwe
resolwe/flow/executors/docker/run.py
FlowExecutor.end
async def end(self): """End process execution.""" try: await self.proc.wait() finally: # Cleanup temporary files. for temporary_file in self.temporary_files: temporary_file.close() self.temporary_files = [] return self.proc...
python
async def end(self): """End process execution.""" try: await self.proc.wait() finally: # Cleanup temporary files. for temporary_file in self.temporary_files: temporary_file.close() self.temporary_files = [] return self.proc...
[ "async", "def", "end", "(", "self", ")", ":", "try", ":", "await", "self", ".", "proc", ".", "wait", "(", ")", "finally", ":", "# Cleanup temporary files.", "for", "temporary_file", "in", "self", ".", "temporary_files", ":", "temporary_file", ".", "close", ...
End process execution.
[ "End", "process", "execution", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/docker/run.py#L318-L328
genialis/resolwe
resolwe/flow/executors/docker/run.py
FlowExecutor.terminate
async def terminate(self): """Terminate a running script.""" # Workaround for pylint issue #1469 # (https://github.com/PyCQA/pylint/issues/1469). cmd = await subprocess.create_subprocess_exec( # pylint: disable=no-member *shlex.split('{} rm -f {}'.format(self.command, self._...
python
async def terminate(self): """Terminate a running script.""" # Workaround for pylint issue #1469 # (https://github.com/PyCQA/pylint/issues/1469). cmd = await subprocess.create_subprocess_exec( # pylint: disable=no-member *shlex.split('{} rm -f {}'.format(self.command, self._...
[ "async", "def", "terminate", "(", "self", ")", ":", "# Workaround for pylint issue #1469", "# (https://github.com/PyCQA/pylint/issues/1469).", "cmd", "=", "await", "subprocess", ".", "create_subprocess_exec", "(", "# pylint: disable=no-member", "*", "shlex", ".", "split", "...
Terminate a running script.
[ "Terminate", "a", "running", "script", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/docker/run.py#L330-L340
genialis/resolwe
resolwe/flow/executors/run.py
iterjson
def iterjson(text): """Decode JSON stream.""" decoder = json.JSONDecoder() while text: obj, ndx = decoder.raw_decode(text) if not isinstance(obj, dict): raise ValueError() text = text[ndx:].lstrip('\r\n') yield obj
python
def iterjson(text): """Decode JSON stream.""" decoder = json.JSONDecoder() while text: obj, ndx = decoder.raw_decode(text) if not isinstance(obj, dict): raise ValueError() text = text[ndx:].lstrip('\r\n') yield obj
[ "def", "iterjson", "(", "text", ")", ":", "decoder", "=", "json", ".", "JSONDecoder", "(", ")", "while", "text", ":", "obj", ",", "ndx", "=", "decoder", ".", "raw_decode", "(", "text", ")", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", "...
Decode JSON stream.
[ "Decode", "JSON", "stream", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L32-L42
genialis/resolwe
resolwe/flow/executors/run.py
BaseFlowExecutor._send_manager_command
async def _send_manager_command(self, *args, **kwargs): """Send an update to manager and terminate the process if it fails.""" resp = await send_manager_command(*args, **kwargs) if resp is False: await self.terminate()
python
async def _send_manager_command(self, *args, **kwargs): """Send an update to manager and terminate the process if it fails.""" resp = await send_manager_command(*args, **kwargs) if resp is False: await self.terminate()
[ "async", "def", "_send_manager_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "await", "send_manager_command", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "resp", "is", "False", ":", "await", "self", ...
Send an update to manager and terminate the process if it fails.
[ "Send", "an", "update", "to", "manager", "and", "terminate", "the", "process", "if", "it", "fails", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L70-L75
genialis/resolwe
resolwe/flow/executors/run.py
BaseFlowExecutor.update_data_status
async def update_data_status(self, **kwargs): """Update (PATCH) Data object. :param kwargs: The dictionary of :class:`~resolwe.flow.models.Data` attributes to be changed. """ await self._send_manager_command(ExecutorProtocol.UPDATE, extra_fields={ ExecutorProtoco...
python
async def update_data_status(self, **kwargs): """Update (PATCH) Data object. :param kwargs: The dictionary of :class:`~resolwe.flow.models.Data` attributes to be changed. """ await self._send_manager_command(ExecutorProtocol.UPDATE, extra_fields={ ExecutorProtoco...
[ "async", "def", "update_data_status", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_send_manager_command", "(", "ExecutorProtocol", ".", "UPDATE", ",", "extra_fields", "=", "{", "ExecutorProtocol", ".", "UPDATE_CHANGESET", ":", "kwargs"...
Update (PATCH) Data object. :param kwargs: The dictionary of :class:`~resolwe.flow.models.Data` attributes to be changed.
[ "Update", "(", "PATCH", ")", "Data", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L96-L104
genialis/resolwe
resolwe/flow/executors/run.py
BaseFlowExecutor.run
async def run(self, data_id, script): """Execute the script and save results.""" logger.debug("Executor for Data with id {} has started.".format(data_id)) try: finish_fields = await self._run(data_id, script) except SystemExit as ex: raise ex except Except...
python
async def run(self, data_id, script): """Execute the script and save results.""" logger.debug("Executor for Data with id {} has started.".format(data_id)) try: finish_fields = await self._run(data_id, script) except SystemExit as ex: raise ex except Except...
[ "async", "def", "run", "(", "self", ",", "data_id", ",", "script", ")", ":", "logger", ".", "debug", "(", "\"Executor for Data with id {} has started.\"", ".", "format", "(", "data_id", ")", ")", "try", ":", "finish_fields", "=", "await", "self", ".", "_run"...
Execute the script and save results.
[ "Execute", "the", "script", "and", "save", "results", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L106-L124
genialis/resolwe
resolwe/flow/executors/run.py
BaseFlowExecutor._create_file
def _create_file(self, filename): """Ensure a new file is created and opened for writing.""" file_descriptor = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL) return os.fdopen(file_descriptor, 'w')
python
def _create_file(self, filename): """Ensure a new file is created and opened for writing.""" file_descriptor = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL) return os.fdopen(file_descriptor, 'w')
[ "def", "_create_file", "(", "self", ",", "filename", ")", ":", "file_descriptor", "=", "os", ".", "open", "(", "filename", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREAT", "|", "os", ".", "O_EXCL", ")", "return", "os", ".", "fdopen", "(", "file...
Ensure a new file is created and opened for writing.
[ "Ensure", "a", "new", "file", "is", "created", "and", "opened", "for", "writing", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L129-L132