code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
try:
if len(result) == 0:
folder = _resolve_folder(project, folderpath, entity_name)
return {"project": project, "folder": folder, "name": None}
else:
validated_results = _validate_resolution_output_length(path, entity_name, result)
return {"proje... | def _format_resolution_output(path, project, folderpath, entity_name, result) | :param path: Path to the object that required resolution; propagated from
command-line
:type path: string
:param project: The potential project the entity belongs to
:type project: string
:param folderpath: Path to the entity
:type folderpath: string
:param entity_name: The name... | 3.563351 | 2.887188 | 1.234194 |
done_objects = {} # Return value
to_resolve_in_batch_paths = [] # Paths to resolve
to_resolve_in_batch_inputs = [] # Project, folderpath, and entity name
for path in paths:
project, folderpath, entity_name = resolve_path(path, expected='entity')
try:
must_resolve, pro... | def resolve_multiple_existing_paths(paths) | :param paths: A list of paths to items that need to be resolved
:type paths: list
:returns: A dictionary mapping a specified path to either its resolved
object or Nones, if the object could not be resolved
:rtype: dict
For each input given in paths, attempts to resolve the path, and retur... | 3.170758 | 2.883559 | 1.099599 |
'''
:param project: project id
:type project: string
:param path: path to where we should look for the folder in question
:type path: string
:param folder_name: name of the folder in question
:type folder_name: string
:returns: A boolean True or False whether the folder exists at the spe... | def check_folder_exists(project, path, folder_name) | :param project: project id
:type project: string
:param path: path to where we should look for the folder in question
:type path: string
:param folder_name: name of the folder in question
:type folder_name: string
:returns: A boolean True or False whether the folder exists at the specified path
... | 4.438644 | 2.202775 | 2.015024 |
'''
:param path: A string to attempt to resolve to an app object
:type path: string
:returns: The describe hash of the app object if found, or None otherwise
:rtype: dict or None
This method parses a string that is expected to perhaps refer to
an app object. If found, its describe hash wil... | def get_app_from_path(path) | :param path: A string to attempt to resolve to an app object
:type path: string
:returns: The describe hash of the app object if found, or None otherwise
:rtype: dict or None
This method parses a string that is expected to perhaps refer to
an app object. If found, its describe hash will be returne... | 5.043443 | 1.757882 | 2.869045 |
'''
:param path: A string to attempt to resolve to a global workflow object
:type path: string
:returns: The describe hash of the global workflow object if found, or None otherwise
:rtype: dict or None
This method parses a string that is expected to perhaps refer to
a global workflow object... | def get_global_workflow_from_path(path) | :param path: A string to attempt to resolve to a global workflow object
:type path: string
:returns: The describe hash of the global workflow object if found, or None otherwise
:rtype: dict or None
This method parses a string that is expected to perhaps refer to
a global workflow object. If found,... | 4.960872 | 1.776814 | 2.792005 |
if not is_hashid(path) and is_version_required and "/" not in path:
raise ResolutionError('Version is required, e.g. "myexec/1.0.0"'.format())
# First, check if the prefix is provided, then we don't have to resolve the name
if path.startswith('app-'):
return resolve_app(path)
elif ... | def resolve_global_executable(path, is_version_required=False) | :param path: A string which is supposed to identify a global executable (app or workflow)
:type path: string
:param is_version_required: If set to True, the path has to specify a specific version/alias, e.g. "myapp/1.0.0"
:type is_version_required: boolean
:returns: The describe hash of the global execu... | 5.589559 | 4.342333 | 1.287225 |
'''
:param path: Path to resolve
:type path: string
:param all_matching_results: Whether to return a list of all matching results
:type all_matching_results: boolean
A thin wrapper over :meth:`resolve_existing_path` which throws an
error if the path does not look like a project and doesn't ... | def resolve_to_objects_or_project(path, all_matching_results=False) | :param path: Path to resolve
:type path: string
:param all_matching_results: Whether to return a list of all matching results
:type all_matching_results: boolean
A thin wrapper over :meth:`resolve_existing_path` which throws an
error if the path does not look like a project and doesn't match a
... | 7.472747 | 3.057619 | 2.443976 |
'''
:param dxid: New job ID to be associated with the handler (localjob IDs also accepted for local runs)
:type dxid: string
Discards the currently stored ID and associates the handler with *dxid*
'''
if dxid is not None:
if not (isinstance(dxid, basestring) ... | def set_id(self, dxid) | :param dxid: New job ID to be associated with the handler (localjob IDs also accepted for local runs)
:type dxid: string
Discards the currently stored ID and associates the handler with *dxid* | 9.253603 | 4.232109 | 2.186523 |
if fields is not None and io is not None:
raise DXError('DXJob.describe: cannot provide non-None values for both fields and io')
describe_input = {}
if fields is not None:
describe_input['fields'] = fields
if io is not None:
describe_input['io... | def describe(self, fields=None, io=None, **kwargs) | :param fields: dict where the keys are field names that should
be returned, and values should be set to True (by default,
all fields are returned)
:type fields: dict
:param io: Include input and output fields in description;
cannot be provided with *fields*; default i... | 3.069823 | 3.357096 | 0.914428 |
dxpy.api.job_add_tags(self._dxid, {"tags": tags}, **kwargs) | def add_tags(self, tags, **kwargs) | :param tags: Tags to add to the job
:type tags: list of strings
Adds each of the specified tags to the job. Takes no
action for tags that are already listed for the job. | 6.341293 | 6.008894 | 1.055318 |
dxpy.api.job_remove_tags(self._dxid, {"tags": tags}, **kwargs) | def remove_tags(self, tags, **kwargs) | :param tags: Tags to remove from the job
:type tags: list of strings
Removes each of the specified tags from the job. Takes
no action for tags that the job does not currently have. | 6.92475 | 6.360837 | 1.088654 |
dxpy.api.job_set_properties(self._dxid, {"properties": properties}, **kwargs) | def set_properties(self, properties, **kwargs) | :param properties: Property names and values given as key-value pairs of strings
:type properties: dict
Given key-value pairs in *properties* for property names and
values, the properties are set on the job for the given
property names. Any property with a value of :const:`None`
... | 7.429538 | 9.030824 | 0.822687 |
'''
:param interval: Number of seconds between queries to the job's state
:type interval: integer
:param timeout: Maximum amount of time to wait, in seconds, until the job is done running
:type timeout: integer
:raises: :exc:`~dxpy.exceptions.DXError` if the timeout is re... | def wait_on_done(self, interval=2, timeout=3600*24*7, **kwargs) | :param interval: Number of seconds between queries to the job's state
:type interval: integer
:param timeout: Maximum amount of time to wait, in seconds, until the job is done running
:type timeout: integer
:raises: :exc:`~dxpy.exceptions.DXError` if the timeout is reached before the job... | 3.333269 | 2.225578 | 1.49771 |
'''
:returns: State of the remote object
:rtype: string
Queries the API server for the job's state.
Note that this function is shorthand for:
dxjob.describe(io=False, **kwargs)["state"]
'''
return self.describe(fields=dict(state=True), **kwargs)["... | def _get_state(self, **kwargs) | :returns: State of the remote object
:rtype: string
Queries the API server for the job's state.
Note that this function is shorthand for:
dxjob.describe(io=False, **kwargs)["state"] | 11.679734 | 2.445012 | 4.776964 |
user_id_or_username = user_id_or_username.lower()
if not user_id_or_username.startswith("user-"):
user_id = "user-" + user_id_or_username.lower()
else:
user_id = user_id_or_username
return user_id | def get_user_id(user_id_or_username) | Gets the user ID based on the value `user_id_or_username` specified on
the command-line, being extra lenient and lowercasing the value in all
cases. | 1.979639 | 2.035876 | 0.972377 |
org_invite_args = {"invitee": user_id}
org_invite_args["level"] = args.level
if "set_bill_to" in args and args.set_bill_to is True:
# /org-x/invite is called in conjunction with /user/new.
org_invite_args["allowBillableActivities"] = True
else:
org_invite_args["allowBillable... | def get_org_invite_args(user_id, args) | Used by:
- `dx new user`
- `dx add member`
PRECONDITION:
- If /org-x/invite is being called in conjunction with /user/new, then
`_validate_new_user_input()` has been called on `args`; otherwise,
the parser must perform all the basic input validation. | 3.856662 | 3.212523 | 1.200509 |
user_new_args = {"username": args.username,
"email": args.email}
if args.first is not None:
user_new_args["first"] = args.first
if args.last is not None:
user_new_args["last"] = args.last
if args.middle is not None:
user_new_args["middle"] = args.middle
... | def _get_user_new_args(args) | PRECONDITION: `_validate_new_user_input()` has been called on `args`. | 2.06223 | 2.056258 | 1.002904 |
# The following may throw if the executable is a workflow with no
# input spec available (because a stage is inaccessible)
exec_inputs = try_call(ExecutableInputs,
executable,
input_name_prefix=input_name_prefix,
active_re... | def _get_input_for_run(args, executable, preset_inputs=None, input_name_prefix=None) | Returns an input dictionary that can be passed to executable.run() | 6.89207 | 6.836308 | 1.008157 |
name = re.sub('^dx ', '', parser.prog)
if subparsers_action is None:
subparsers_action = subparsers
if isinstance(categories, basestring):
categories = (categories, )
parser_map[name] = parser
if add_help:
_help = subparsers_action._choices_actions[-1].help
pars... | def register_parser(parser, subparsers_action=None, categories=('other', ), add_help=True) | Attaches `parser` to the global ``parser_map``. If `add_help` is truthy,
then adds the helpstring of `parser` into the output of ``dx help...``, for
each category in `categories`.
:param subparsers_action: A special action object that is returned by
``ArgumentParser.add_subparsers(...)``, or None.
... | 3.955855 | 3.825419 | 1.034097 |
if isinstance(e, urllib3.exceptions.ProtocolError):
e = e.args[1]
if isinstance(e, (socket.gaierror, socket.herror)):
return True
if isinstance(e, socket.error) and e.errno in _RETRYABLE_SOCKET_ERRORS:
return True
if isinstance(e, urllib3.exceptions.NewConnectionError):
... | def _is_retryable_exception(e) | Returns True if the exception is always safe to retry.
This is True if the client was never able to establish a connection
to the server (for example, name resolution failed or the connection
could otherwise not be initialized).
Conservatively, if we can't tell whether a network connection could
h... | 2.048567 | 2.221991 | 0.921951 |
''' Extract a useful error message from the last thrown exception '''
last_exc_type, last_error, last_traceback = sys.exc_info()
if isinstance(last_error, exceptions.DXAPIError):
# Using the same code path as below would not
# produce a useful message when the error contains a
# 'det... | def _extract_msg_from_last_exception() | Extract a useful error message from the last thrown exception | 7.483786 | 6.92369 | 1.080896 |
'''
Returns the time in seconds that we should wait.
:param num_attempts: number of attempts that have been made to the
resource, including the most recent failed one
:type num_attempts: int
'''
if response is not None and response.status == 503 and 'retry-after' in response.headers:
... | def _calculate_retry_delay(response, num_attempts) | Returns the time in seconds that we should wait.
:param num_attempts: number of attempts that have been made to the
resource, including the most recent failed one
:type num_attempts: int | 4.275826 | 3.184502 | 1.342698 |
'''
:param host: API server hostname
:type host: string
:param port: API server port. If not specified, *port* is guessed based on *protocol*.
:type port: string
:param protocol: Either "http" or "https"
:type protocol: string
Overrides the current settings for which API server to commu... | def set_api_server_info(host=None, port=None, protocol=None) | :param host: API server hostname
:type host: string
:param port: API server port. If not specified, *port* is guessed based on *protocol*.
:type port: string
:param protocol: Either "http" or "https"
:type protocol: string
Overrides the current settings for which API server to communicate
w... | 2.504537 | 1.496632 | 1.673449 |
if host_override is not None or port_override is not None:
if host_override is None or port_override is None:
raise exceptions.DXError("Both host and port must be specified if either is specified")
return protocol + '://' + host_override + ':' + str(port_override)
elif APISERVER... | def get_auth_server_name(host_override=None, port_override=None, protocol='https') | Chooses the auth server name from the currently configured API server name.
Raises DXError if the auth server name cannot be guessed and the overrides
are not provided (or improperly provided). | 2.097988 | 1.999477 | 1.049268 |
if not globalworkflow_desc or \
globalworkflow_desc['class'] != 'globalworkflow' or \
not 'regionalOptions' in globalworkflow_desc:
return globalworkflow_desc
for region, config in globalworkflow_desc['regionalOptions'].items():
workflow_id = config['workflow']
... | def append_underlying_workflow_describe(globalworkflow_desc) | Adds the "workflowDescribe" field to the config for each region of
the global workflow. The value is the description of an underlying
workflow in that region. | 3.071335 | 2.719344 | 1.129439 |
'''
:param job_id: Job ID
:type job_id: string
:param field_name_and_maybe_index: Field name, plus possibly ".N" where N is an array index
:type field_name_and_maybe_index: string
:returns: dict of JBOR
'''
link = {"$dnanexus_link": {"job": job_id}}
if '.' in field_name_and_maybe_ind... | def _construct_jbor(job_id, field_name_and_maybe_index) | :param job_id: Job ID
:type job_id: string
:param field_name_and_maybe_index: Field name, plus possibly ".N" where N is an array index
:type field_name_and_maybe_index: string
:returns: dict of JBOR | 2.320867 | 1.699526 | 1.365596 |
if strip_prefix and self.input_name_prefix is not None:
for i in new_inputs:
if i.startswith(self.input_name_prefix):
self.inputs[i[len(self.input_name_prefix):]] = new_inputs[i]
else:
self.inputs.update(new_inputs) | def update(self, new_inputs, strip_prefix=True) | Updates the inputs dictionary with the key/value pairs from new_inputs, overwriting existing keys. | 1.920299 | 1.773908 | 1.082524 |
input_paths = [quad[1] for quad in self.requires_resolution]
results = resolve_multiple_existing_paths(input_paths)
for input_name, input_value, input_class, input_index in self.requires_resolution:
project = results[input_value]['project']
folderpath = results[i... | def _update_requires_resolution_inputs(self) | Updates self.inputs with resolved input values (the input values that were provided
as paths to items that require resolutions, eg. folder or job/analyses ids) | 2.992466 | 2.858035 | 1.047036 |
def replacer(matchobj):
if ord(matchobj.group(1)) == 127:
return "\\x7f"
if ord(matchobj.group(1)) == 92: # backslash
return "\\\\"
return REPLACEMENT_TABLE[ord(matchobj.group(1))]
return re.sub("([\\000-\\037\\134\\177])", replacer, u) | def escape_unicode_string(u) | Escapes the nonprintable chars 0-31 and 127, and backslash;
preferably with a friendly equivalent such as '\n' if available, but
otherwise with a Python-style backslashed hex escape. | 3.25364 | 3.095028 | 1.051247 |
''' Tree pretty printer.
Expects trees to be given as mappings (dictionaries). Keys will be printed; values will be traversed if they are
mappings. To preserve order, use collections.OrderedDict.
Example:
print format_tree(collections.OrderedDict({'foo': 0, 'bar': {'xyz': 0}}))
'''
fo... | def format_tree(tree, root=None) | Tree pretty printer.
Expects trees to be given as mappings (dictionaries). Keys will be printed; values will be traversed if they are
mappings. To preserve order, use collections.OrderedDict.
Example:
print format_tree(collections.OrderedDict({'foo': 0, 'bar': {'xyz': 0}})) | 2.975997 | 1.978693 | 1.504021 |
''' Table pretty printer.
Expects tables to be given as arrays of arrays.
Example:
print format_table([[1, "2"], [3, "456"]], column_names=['A', 'B'])
'''
if len(table) > 0:
col_widths = [0] * len(list(table)[0])
elif column_specs is not None:
col_widths = [0] * (len(c... | def format_table(table, column_names=None, column_specs=None, max_col_width=32,
report_dimensions=False) | Table pretty printer.
Expects tables to be given as arrays of arrays.
Example:
print format_table([[1, "2"], [3, "456"]], column_names=['A', 'B']) | 1.932227 | 1.804284 | 1.070911 |
result = re.sub('"{}": \\[\r?\n\\s*'.format(array_name), '"{}": ['.format(array_name), json_string, flags=re.MULTILINE)
flatten_regexp = re.compile('"{}": \\[(.*)(?<=,)\r?\n\\s*'.format(array_name), flags=re.MULTILINE)
while flatten_regexp.search(result):
result = flatten_regexp.sub('"{}": [\\... | def flatten_json_array(json_string, array_name) | Flattens all arrays with the same name in the JSON string
:param json_string: JSON string
:type json_string: str
:param array_name: Array name to flatten
:type array_name: str | 2.453167 | 2.437629 | 1.006374 |
'''
:param title: Workflow title (optional)
:type title: string
:param summary: Workflow summary (optional)
:type summary: string
:param description: Workflow description (optional)
:type description: string
:param output_folder: Default output folder of the workflow (optional)
:type... | def new_dxworkflow(title=None, summary=None, description=None, output_folder=None, init_from=None, **kwargs) | :param title: Workflow title (optional)
:type title: string
:param summary: Workflow summary (optional)
:type summary: string
:param description: Workflow description (optional)
:type description: string
:param output_folder: Default output folder of the workflow (optional)
:type output_fold... | 3.820858 | 1.198084 | 3.18914 |
def _set_dx_hash(kwargs, dxhash, key, new_key=None):
new_key = key if new_key is None else new_key
if key in kwargs:
if kwargs[key] is not None:
dxhash[new_key] = kwargs[key]
del kwargs[key]
if "init_from" in kwargs:
... | def _new(self, dx_hash, **kwargs) | :param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes.
:type dx_hash: dict
:param title: Workflow title (optional)
:type title: string
:param summary: Workflow summary (optional)
:type summary: ... | 2.256489 | 1.871367 | 1.205797 |
'''
:param stage: A stage ID, name, or index (stage index is the number n for the nth stage, starting from 0; can be provided as an int or a string)
:type stage: int or string
:returns: The stage ID (this is a no-op if it was already a stage ID)
:raises: :class:`~dxpy.exceptions.... | def _get_stage_id(self, stage) | :param stage: A stage ID, name, or index (stage index is the number n for the nth stage, starting from 0; can be provided as an int or a string)
:type stage: int or string
:returns: The stage ID (this is a no-op if it was already a stage ID)
:raises: :class:`~dxpy.exceptions.DXError` if *stage* ... | 3.288272 | 2.406272 | 1.366542 |
'''
:param executable: string or a handler for an app or applet
:type executable: string, DXApplet, or DXApp
:param stage_id: id for the stage (optional)
:type stage_id: string
:param name: name for the stage (optional)
:type name: string
:param folder: de... | def add_stage(self, executable, stage_id=None, name=None, folder=None, stage_input=None, instance_type=None,
edit_version=None, **kwargs) | :param executable: string or a handler for an app or applet
:type executable: string, DXApplet, or DXApp
:param stage_id: id for the stage (optional)
:type stage_id: string
:param name: name for the stage (optional)
:type name: string
:param folder: default output folder ... | 3.008541 | 1.557761 | 1.931324 |
'''
:param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:returns: Hash of stage descriptor in workflow
'''
stage_id = self._get_stage_id(stage)
result = next((stage... | def get_stage(self, stage, **kwargs) | :param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:returns: Hash of stage descriptor in workflow | 5.324955 | 2.203561 | 2.416523 |
'''
:param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param edit_version: if provided, the edit version of the workflow that should be modified; if not provided, the current edit versio... | def remove_stage(self, stage, edit_version=None, **kwargs) | :param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param edit_version: if provided, the edit version of the workflow that should be modified; if not provided, the current edit version will be used (opti... | 4.115467 | 2.078716 | 1.979812 |
'''
:param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param new_index: The new position in the order of stages that the specified stage should have (where 0 indicates the first stage)
... | def move_stage(self, stage, new_index, edit_version=None, **kwargs) | :param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param new_index: The new position in the order of stages that the specified stage should have (where 0 indicates the first stage)
:type new_ind... | 3.865064 | 1.831969 | 2.109787 |
'''
:param input_str: A string of one of the forms: "<exported input field name>", "<explicit workflow input field name>", "<stage ID>.<input field name>", "<stage index>.<input field name>", "<stage name>.<input field name>"
:type input_str: string
:returns: If the given form was one of... | def _get_input_name(self, input_str, region=None, describe_output=None) | :param input_str: A string of one of the forms: "<exported input field name>", "<explicit workflow input field name>", "<stage ID>.<input field name>", "<stage index>.<input field name>", "<stage name>.<input field name>"
:type input_str: string
:returns: If the given form was one of those which uses th... | 6.082314 | 1.842202 | 3.301654 |
'''
:param text: String to be tab-completed; still in escaped form
:type text: string
:param delim_pos: index of last unescaped "/" in text
:type delim_pos: int
:param dxproj: DXProject handler to use
:type dxproj: DXProject
:param folderpath: Unescaped path in which to search for folder... | def get_folder_matches(text, delim_pos, dxproj, folderpath) | :param text: String to be tab-completed; still in escaped form
:type text: string
:param delim_pos: index of last unescaped "/" in text
:type delim_pos: int
:param dxproj: DXProject handler to use
:type dxproj: DXProject
:param folderpath: Unescaped path in which to search for folder matches
... | 4.071644 | 1.893395 | 2.150446 |
'''
:param text: String to be tab-completed; still in escaped form
:type text: string
:param delim_pos: index of last unescaped "/" or ":" in text
:type delim_pos: int
:param dxproj: DXProject handler to use
:type dxproj: DXProject
:param folderpath: Unescaped path in which to search for... | def get_data_matches(text, delim_pos, dxproj, folderpath, classname=None,
typespec=None, visibility=None) | :param text: String to be tab-completed; still in escaped form
:type text: string
:param delim_pos: index of last unescaped "/" or ":" in text
:type delim_pos: int
:param dxproj: DXProject handler to use
:type dxproj: DXProject
:param folderpath: Unescaped path in which to search for data object... | 4.109764 | 1.9411 | 2.117235 |
'''
:param dxid: Value to verify as a DNAnexus ID of class *expected_class*
:param expected_classes: Single string or list of strings of allowed classes of the ID, e.g. "file" or ["project", "container"]
:type expected_classes: string or list of strings
:raises: :exc:`~dxpy.exceptions.DXError` if *d... | def verify_string_dxid(dxid, expected_classes) | :param dxid: Value to verify as a DNAnexus ID of class *expected_class*
:param expected_classes: Single string or list of strings of allowed classes of the ID, e.g. "file" or ["project", "container"]
:type expected_classes: string or list of strings
:raises: :exc:`~dxpy.exceptions.DXError` if *dxid* is not ... | 2.23632 | 1.574541 | 1.4203 |
'''
:param dxid: New ID to be associated with the handler
:type dxid: string
Discards the currently stored ID and associates the handler with *dxid*
'''
if dxid is not None:
verify_string_dxid(dxid, self._class)
self._dxid = dxid | def set_id(self, dxid) | :param dxid: New ID to be associated with the handler
:type dxid: string
Discards the currently stored ID and associates the handler with *dxid* | 6.197567 | 3.178561 | 1.949803 |
'''
:param project: Project ID in which to create the new remote object
:type project: string
:param name: Name for the object
:type name: string
:param tags: Tags to add for the object
:type tags: list of strings
:param types: Types to add to the object
... | def new(self, **kwargs) | :param project: Project ID in which to create the new remote object
:type project: string
:param name: Name for the object
:type name: string
:param tags: Tags to add for the object
:type tags: list of strings
:param types: Types to add to the object
:type types: ... | 5.22427 | 1.707572 | 3.059473 |
'''
:param dxid: Object ID or a DNAnexus link (a dict with key "$dnanexus_link"); if a project ID is provided in the DNAnexus link, it will be used as *project* unless *project* has been explictly provided
:type dxid: string or dict
:param project: Project ID
:type project: strin... | def set_ids(self, dxid, project=None) | :param dxid: Object ID or a DNAnexus link (a dict with key "$dnanexus_link"); if a project ID is provided in the DNAnexus link, it will be used as *project* unless *project* has been explictly provided
:type dxid: string or dict
:param project: Project ID
:type project: string
Discards ... | 4.967628 | 1.940477 | 2.560003 |
if self._dxid is None:
raise DXError('This {handler} handler has not been initialized with a {_class} ID and cannot be described'.format(
handler=self.__class__.__name__,
_class=self._class)
)
if (incl_properties or incl_details) and (fi... | def describe(self, incl_properties=False, incl_details=False, fields=None, default_fields=None, **kwargs) | :param fields: set of fields to include in the output, for
example ``{'name', 'modified'}``. The field ``id`` is always
implicitly included. If ``fields`` is specified, the default
fields are not included (that is, only the fields specified
here, and ``id``, are included)... | 2.843469 | 2.93943 | 0.967354 |
self._add_types(self._dxid, {"types": types}, **kwargs) | def add_types(self, types, **kwargs) | :param types: Types to add to the object
:type types: list of strings
:raises: :class:`~dxpy.exceptions.DXAPIError` if the object is not in the "open" state
Adds each of the specified types to the remote object. Takes no
action for types that are already listed for the object. | 18.489666 | 9.4013 | 1.966714 |
self._remove_types(self._dxid, {"types": types}, **kwargs) | def remove_types(self, types, **kwargs) | :param types: Types to remove from the object
:type types: list of strings
:raises: :class:`~dxpy.exceptions.DXAPIError` if the object is not in the "open" state
Removes each the specified types from the remote object. Takes
no action for types that the object does not currently have. | 16.094786 | 10.466966 | 1.537674 |
return self._set_details(self._dxid, details, **kwargs) | def set_details(self, details, **kwargs) | :param details: Details to set for the object
:type details: dict or list
:raises: :class:`~dxpy.exceptions.DXAPIError` if the object is not in the "open" state
Sets the details for the remote object with the specified value.
If the input contains the string ``"$dnanexus_link"`` as a ke... | 11.69878 | 10.412347 | 1.123549 |
return self._rename(self._dxid, {"project": self._proj,
"name": name}, **kwargs) | def rename(self, name, **kwargs) | :param name: New name for the object
:type name: string
Renames the remote object.
The name is changed on the copy of the object in the project
associated with the handler. | 14.647871 | 13.684221 | 1.070421 |
self._set_properties(self._dxid, {"project": self._proj,
"properties": properties},
**kwargs) | def set_properties(self, properties, **kwargs) | :param properties: Property names and values given as key-value pairs of strings
:type properties: dict
Given key-value pairs in *properties* for property names and
values, the properties are set on the object for the given
property names. Any property with a value of :const:`None`
... | 12.91025 | 10.635627 | 1.213868 |
self._add_tags(self._dxid, {"project": self._proj, "tags": tags},
**kwargs) | def add_tags(self, tags, **kwargs) | :param tags: Tags to add to the object
:type tags: list of strings
Adds each of the specified tags to the remote object. Takes no
action for tags that are already listed for the object.
The tags are added to the copy of the object in the project
associated with the handler. | 11.013156 | 10.940007 | 1.006686 |
self._remove_tags(self._dxid, {"project": self._proj, "tags": tags},
**kwargs) | def remove_tags(self, tags, **kwargs) | :param tags: Tags to remove from the object
:type tags: list of strings
Removes each of the specified tags from the remote object. Takes
no action for tags that the object does not currently have.
The tags are removed from the copy of the object in the project
associated with t... | 11.367187 | 10.744906 | 1.057914 |
'''
:raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
Permanently removes the associated remote object from the
associated project.
'''
if self._proj is None:
raise DXError("Remove called when a project ID was not associate... | def remove(self, **kwargs) | :raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
Permanently removes the associated remote object from the
associated project. | 5.70686 | 3.514241 | 1.623924 |
'''
:param folder: Folder route to which to move the object
:type folder: string
:raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
Moves the associated remote object to *folder*.
'''
if self._proj is None:
raise DX... | def move(self, folder, **kwargs) | :param folder: Folder route to which to move the object
:type folder: string
:raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
Moves the associated remote object to *folder*. | 6.494699 | 3.070376 | 2.115278 |
'''
:param project: Destination project ID
:type project: string
:param folder: Folder route to which to move the object
:type folder: string
:raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
:returns: An object handler for the n... | def clone(self, project, folder="/", **kwargs) | :param project: Destination project ID
:type project: string
:param folder: Folder route to which to move the object
:type folder: string
:raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object
:returns: An object handler for the new cloned object
... | 4.4773 | 2.207668 | 2.028068 |
sessions_dir = os.path.join(self._user_conf_dir, "sessions")
try:
from psutil import Process, pid_exists
if cleanup:
try:
session_dirs = os.listdir(sessions_dir)
except OSError as e:
# Silently skip... | def get_session_conf_dir(self, cleanup=False) | Tries to find the session configuration directory by looking in ~/.dnanexus_config/sessions/<PID>,
where <PID> is pid of the parent of this process, then its parent, and so on.
If none of those exist, the path for the immediate parent is given, even if it doesn't exist.
If *cleanup* is True, lo... | 3.025898 | 3.002061 | 1.00794 |
'''
:param object_id: Object ID or the object handler itself
:type object_id: string or :class:`~dxpy.bindings.DXDataObject`
:param project_id: A project ID, if creating a cross-project DXLink
:type project_id: string
:param field: A field name, if creating a job-based object reference
:type... | def dxlink(object_id, project_id=None, field=None) | :param object_id: Object ID or the object handler itself
:type object_id: string or :class:`~dxpy.bindings.DXDataObject`
:param project_id: A project ID, if creating a cross-project DXLink
:type project_id: string
:param field: A field name, if creating a job-based object reference
:type field: stri... | 3.04287 | 1.337682 | 2.274733 |
'''
:param x: A potential DNAnexus link
Returns whether *x* appears to be a DNAnexus link (is a dict with
key ``"$dnanexus_link"``) with a referenced data object.
'''
if not isinstance(x, dict):
return False
if '$dnanexus_link' not in x:
return False
link = x['$dnanexus_... | def is_dxlink(x) | :param x: A potential DNAnexus link
Returns whether *x* appears to be a DNAnexus link (is a dict with
key ``"$dnanexus_link"``) with a referenced data object. | 3.63445 | 1.840859 | 1.974323 |
'''
:param link: A DNAnexus link
:type link: dict
:returns: (Object ID, Project ID) if the link is to a data object (or :const:`None`
if no project specified in the link), or (Job ID, Field) if the link is
a job-based object reference (JBOR).
:rtype: tuple
Get the object ID and ... | def get_dxlink_ids(link) | :param link: A DNAnexus link
:type link: dict
:returns: (Object ID, Project ID) if the link is to a data object (or :const:`None`
if no project specified in the link), or (Job ID, Field) if the link is
a job-based object reference (JBOR).
:rtype: tuple
Get the object ID and detail from ... | 3.017797 | 1.296198 | 2.328193 |
'''
:param id_or_link: String containing an object ID or dict containing a DXLink
:type id_or_link: string or dict
:param project: String project ID to use as the context if the the object is a data object
:type project: string
:rtype: :class:`~dxpy.bindings.DXObject`, :class:`~dxpy.bindings.DXA... | def get_handler(id_or_link, project=None) | :param id_or_link: String containing an object ID or dict containing a DXLink
:type id_or_link: string or dict
:param project: String project ID to use as the context if the the object is a data object
:type project: string
:rtype: :class:`~dxpy.bindings.DXObject`, :class:`~dxpy.bindings.DXApp`, or :cla... | 3.640557 | 2.289949 | 1.589798 |
'''
:param id_or_link: String containing an object ID or dict containing a DXLink,
or a list of object IDs or dicts containing a DXLink.
Given an object ID, calls :meth:`~dxpy.bindings.DXDataObject.describe` on the object.
Example::
describe("file-1234")
Given a li... | def describe(id_or_link, **kwargs) | :param id_or_link: String containing an object ID or dict containing a DXLink,
or a list of object IDs or dicts containing a DXLink.
Given an object ID, calls :meth:`~dxpy.bindings.DXDataObject.describe` on the object.
Example::
describe("file-1234")
Given a list of object... | 4.253234 | 2.230789 | 1.906606 |
# TODO: link to /container-xxxx/describe
api_method = dxpy.api.container_describe
if isinstance(self, DXProject):
api_method = dxpy.api.project_describe
self._desc = api_method(self._dxid, **kwargs)
return self._desc | def describe(self, **kwargs) | :returns: A hash containing attributes of the project or container.
:rtype: dict
Returns a hash with key-value pairs as specified by the API
specification for the `/project-xxxx/describe
<https://wiki.dnanexus.com/API-Specification-v1.0.0/Projects#API-method%3A-%2Fproject-xxxx%2Fdescrib... | 5.938693 | 4.197165 | 1.41493 |
api_method = dxpy.api.container_new_folder
if isinstance(self, DXProject):
api_method = dxpy.api.project_new_folder
api_method(self._dxid, {"folder": folder,
"parents": parents},
**kwargs) | def new_folder(self, folder, parents=False, **kwargs) | :param folder: Full path to the new folder to create
:type folder: string
:param parents: If True, recursively create any parent folders that are missing
:type parents: boolean
Creates a new folder in the project or container. | 4.250572 | 4.491837 | 0.946288 |
# TODO: it would be nice if we could supply describe
# fields/defaultFields in a similar way to what we pass to the
# high-level describe method, rather than having to construct
# the literal API input
api_method = dxpy.api.container_list_folder
if isinstance(se... | def list_folder(self, folder="/", describe=False, only="all", includeHidden=False, **kwargs) | :param folder: Full path to the folder to list
:type folder: string
:param describe: If True, returns the output of ``/describe`` on each object (see below for notes)
:type describe: bool or dict
:param only: Indicate "objects" for only objects, "folders" for only folders, or "all" for b... | 6.723723 | 7.118259 | 0.944574 |
api_method = dxpy.api.container_move
if isinstance(self, DXProject):
api_method = dxpy.api.project_move
api_method(self._dxid, {"objects": objects,
"folders": folders,
"destination": destination},
... | def move(self, destination, objects=[], folders=[], **kwargs) | :param destination: Path of destination folder
:type destination: string
:param objects: List of object IDs to move
:type objects: list of strings
:param folders: List of full paths to folders to move
:type folders: list of strings
Moves the specified objects and folders... | 3.839719 | 5.135964 | 0.747614 |
api_method = dxpy.api.container_move
if isinstance(self, DXProject):
api_method = dxpy.api.project_move
api_method(self._dxid, {"folders": [folder],
"destination": destination},
**kwargs) | def move_folder(self, folder, destination, **kwargs) | :param folder: Full path to the folder to move
:type folder: string
:param destination: Full path to the destination folder that will contain *folder*
:type destination: string
Moves *folder* to reside in *destination* in the same project or
container. All objects and subfolders... | 4.666982 | 5.765654 | 0.809445 |
api_method = dxpy.api.container_remove_folder
if isinstance(self, DXProject):
api_method = dxpy.api.project_remove_folder
completed = False
while not completed:
resp = api_method(self._dxid,
{"folder": folder, "recurse": rec... | def remove_folder(self, folder, recurse=False, force=False, **kwargs) | :param folder: Full path to the folder to remove
:type folder: string
:param recurse: If True, recursively remove all objects and subfolders in the folder
:type recurse: bool
:param force: If True, will suppress errors for folders that do not exist
:type force: bool
Remo... | 4.468411 | 4.948023 | 0.90307 |
api_method = dxpy.api.container_remove_objects
if isinstance(self, DXProject):
api_method = dxpy.api.project_remove_objects
api_method(self._dxid,
{"objects": objects, "force": force},
always_retry=force, # api call is idempotent under... | def remove_objects(self, objects, force=False, **kwargs) | :param objects: List of object IDs to remove from the project or container
:type objects: list of strings
:param force: If True, will suppress errors for objects that do not exist
:type force: bool
Removes the specified objects from the project or container.
Removal propagates ... | 5.958453 | 6.625721 | 0.899291 |
api_method = dxpy.api.container_clone
if isinstance(self, DXProject):
api_method = dxpy.api.project_clone
return api_method(self._dxid,
{"objects": objects,
"folders": folders,
"project": contai... | def clone(self, container, destination="/", objects=[], folders=[], parents=False, **kwargs) | :param container: Destination container ID
:type container: string
:param destination: Path of destination folder in the destination container
:type destination: string
:param objects: List of object IDs to move
:type objects: list of strings
:param folders: List of full ... | 3.343455 | 4.494014 | 0.74398 |
input_hash = {}
input_hash["name"] = name
if summary is not None:
input_hash["summary"] = summary
if description is not None:
input_hash["description"] = description
if protected is not None:
input_hash["protected"] = protected
... | def new(self, name, summary=None, description=None, protected=None,
restricted=None, download_restricted=None, contains_phi=None, tags=None,
properties=None, bill_to=None, **kwargs) | :param name: The name of the project
:type name: string
:param summary: If provided, a short summary of what the project contains
:type summary: string
:param description: If provided, the new project description
:type name: string
:param protected: If provided, whether t... | 1.685832 | 1.741662 | 0.967945 |
update_hash = {}
if name is not None:
update_hash["name"] = name
if summary is not None:
update_hash["summary"] = summary
if description is not None:
update_hash["description"] = description
if protected is not None:
update... | def update(self, name=None, summary=None, description=None, protected=None,
restricted=None, download_restricted=None, version=None, **kwargs) | :param name: If provided, the new project name
:type name: string
:param summary: If provided, the new project summary
:type summary: string
:param description: If provided, the new project description
:type name: string
:param protected: If provided, whether the project ... | 1.533368 | 1.653329 | 0.927443 |
return dxpy.api.project_invite(self._dxid,
{"invitee": invitee, "level": level,
"suppressEmailNotification": not send_email},
**kwargs) | def invite(self, invitee, level, send_email=True, **kwargs) | :param invitee: Username (of the form "user-USERNAME") or email address of person to be invited to the project; use "PUBLIC" to make the project publicly available (in which case level must be set to "VIEW").
:type invitee: string
:param level: Permissions level that the invitee would get ("VIEW", "UPLO... | 5.531439 | 6.525678 | 0.847642 |
input_hash = {}
input_hash[member] = level
return dxpy.api.project_decrease_permissions(self._dxid,
input_hash,
**kwargs) | def decrease_perms(self, member, level, **kwargs) | :param member: Username (of the form "user-USERNAME") of the project member whose permissions will be decreased.
:type member: string
:param level: Permissions level that the member will have after this operation (None, "VIEW", "UPLOAD", or "CONTRIBUTE")
:type level: string or None
Decr... | 8.311579 | 8.456163 | 0.982902 |
return dxpy.api.project_set_properties(self._dxid, {"properties": properties}, **kwargs) | def set_properties(self, properties, **kwargs) | :param properties: Property names and values given as key-value pairs of strings
:type properties: dict
Given key-value pairs in *properties* for property names and
values, the properties are set on the project for the given
property names. Any property with a value of :const:`None`
... | 6.063358 | 7.087186 | 0.855538 |
from .utils.printing import fill
return '\n'.join(fill(line) for line in traceback.format_exception_only(type(e), e)) | def format_exception(e) | Returns a string containing the type and text of the exception. | 5.332405 | 5.022976 | 1.061603 |
'''Exits the program, printing information about the last exception (if
any) and an optional error message. Uses *exception* instead if provided.
:param code: Exit code.
:type code: integer (valid exit code, 0-255)
:param message: Message to be printed after the exception information.
:type me... | def exit_with_exc_info(code=1, message='', print_tb=False, exception=None) | Exits the program, printing information about the last exception (if
any) and an optional error message. Uses *exception* instead if provided.
:param code: Exit code.
:type code: integer (valid exit code, 0-255)
:param message: Message to be printed after the exception information.
:type message: ... | 3.120036 | 1.704486 | 1.830485 |
'''Exits the program, printing information about the last exception (if
any) and an optional error message. Uses *exception* instead if provided.
Uses **expected_exceptions** to set the error code decide whether to
suppress the error traceback.
:param message: Message to be printed after the exce... | def err_exit(message='', code=None, expected_exceptions=default_expected_exceptions, arg_parser=None,
ignore_sigpipe=True, exception=None) | Exits the program, printing information about the last exception (if
any) and an optional error message. Uses *exception* instead if provided.
Uses **expected_exceptions** to set the error code decide whether to
suppress the error traceback.
:param message: Message to be printed after the exception i... | 4.429681 | 1.714085 | 2.584283 |
"Returns a one-line description of the error."
output = self.msg + ", code " + str(self.code)
output += ". Request Time={}, Request ID={}".format(self.timestamp, self.req_id)
if self.name != self.__class__.__name__:
output = self.name + ": " + output
return output | def error_message(self) | Returns a one-line description of the error. | 5.584613 | 4.928307 | 1.133171 |
if self._dxid is not None:
return dxpy.api.global_workflow_publish(self._dxid, **kwargs)
else:
return dxpy.api.global_workflow_publish('globalworkflow-' + self._name, alias=self._alias, **kwargs) | def publish(self, **kwargs) | Publishes the global workflow, so all users can find it and use it on the platform.
The current user must be a developer of the workflow. | 4.759044 | 4.006808 | 1.187739 |
assert(describe_output is None or describe_output.get('class', '') == 'globalworkflow')
if region is None:
raise DXError(
'DXGlobalWorkflow: region must be provided to get an underlying workflow')
# Perhaps we have cached it already
if region in sel... | def describe_underlying_workflow(self, region, describe_output=None) | :param region: region name
:type region: string
:param describe_output: description of a global workflow
:type describe_output: dict
:returns: object description of a workflow
:rtype: : dict
Returns an object description of an underlying workflow from a given region. | 3.675917 | 3.617596 | 1.016122 |
assert(describe_output is None or describe_output.get('class') == 'globalworkflow')
if region is None:
raise DXError(
'DXGlobalWorkflow: region must be provided to get an underlying workflow')
# Perhaps we have cached it already
if region in self._w... | def get_underlying_workflow(self, region, describe_output=None) | :param region: region name
:type region: string
:param describe_output: description of a global workflow
:type describe_output: dict
:returns: object handler of a workflow
:rtype: :class:`~dxpy.bindings.dxworkflow.DXWorkflow`
Returns an object handler of an underlying wo... | 3.938778 | 3.544623 | 1.111198 |
assert(describe_output is None or describe_output.get('class') == 'globalworkflow')
underlying_workflow_desc = self.describe_underlying_workflow(region,
describe_output=describe_output)
for field in ['inputs', 'output... | def append_underlying_workflow_desc(self, describe_output, region) | :param region: region name
:type region: string
:param describe_output: description of a global workflow
:type describe_output: dict
:returns: object description of the global workflow
:rtype: : dict
Appends stages, inputs, outputs and other workflow-specific metadata to... | 4.274083 | 3.783637 | 1.129623 |
region = dxpy.api.project_describe(project,
input_params={"fields": {"region": True}})["region"]
dxworkflow = self.get_underlying_workflow(region)
return dxworkflow._get_run_input(workflow_input, **kwargs) | def _get_run_input(self, workflow_input, project=None, **kwargs) | Checks the region in which the global workflow is run
and returns the input associated with the underlying workflow
from that region. | 5.489191 | 4.592323 | 1.195297 |
wrapped_stream = None
try:
wrapped_stream = getattr(sys, stream_name)
if hasattr(wrapped_stream, '_original_stream'):
setattr(sys, stream_name, wrapped_stream._original_stream)
yield
finally:
if wrapped_stream:
setattr(sys, stream_name, wrapped_st... | def unwrap_stream(stream_name) | Temporarily unwraps a given stream (stdin, stdout, or stderr) to undo the effects of wrap_stdio_in_codecs(). | 2.369576 | 2.108892 | 1.123611 |
'''
:param dxid: file ID
:type dxid: string
:rtype: :class:`~dxpy.bindings.dxfile.DXFile`
Given the object ID of an uploaded file, returns a remote file
handler that is a Python file-like object.
Example::
with open_dxfile("file-xxxx") as fd:
for line in fd:
... | def open_dxfile(dxid, project=None, mode=None, read_buffer_size=dxfile.DEFAULT_BUFFER_SIZE) | :param dxid: file ID
:type dxid: string
:rtype: :class:`~dxpy.bindings.dxfile.DXFile`
Given the object ID of an uploaded file, returns a remote file
handler that is a Python file-like object.
Example::
with open_dxfile("file-xxxx") as fd:
for line in fd:
...
Not... | 3.896573 | 1.47326 | 2.644865 |
'''
:param mode: One of "w" or "a" for write and append modes, respectively
:type mode: string
:rtype: :class:`~dxpy.bindings.dxfile.DXFile`
Additional optional parameters not listed: all those under
:func:`dxpy.bindings.DXDataObject.new`.
Creates a new remote file object that is ready to ... | def new_dxfile(mode=None, write_buffer_size=dxfile.DEFAULT_BUFFER_SIZE, expected_file_size=None, file_is_mmapd=False,
**kwargs) | :param mode: One of "w" or "a" for write and append modes, respectively
:type mode: string
:rtype: :class:`~dxpy.bindings.dxfile.DXFile`
Additional optional parameters not listed: all those under
:func:`dxpy.bindings.DXDataObject.new`.
Creates a new remote file object that is ready to be written t... | 3.736938 | 1.354581 | 2.75874 |
'''
:param dxid: DNAnexus file ID or DXFile (file handler) object
:type dxid: string or DXFile
:param filename: Local filename
:type filename: string
:param append: If True, appends to the local file (default is to truncate local file if it exists)
:type append: boolean
:param project: p... | def download_dxfile(dxid, filename, chunksize=dxfile.DEFAULT_BUFFER_SIZE, append=False, show_progress=False,
project=None, describe_output=None, **kwargs) | :param dxid: DNAnexus file ID or DXFile (file handler) object
:type dxid: string or DXFile
:param filename: Local filename
:type filename: string
:param append: If True, appends to the local file (default is to truncate local file if it exists)
:type append: boolean
:param project: project to us... | 5.75758 | 1.52726 | 3.769874 |
# Use 'a' mode because we will be responsible for closing the file
# ourselves later (if requested).
handler = new_dxfile(media_type=media_type, mode='a', **kwargs)
# For subsequent API calls, don't supply the dataobject metadata
# parameters that are only needed at creation time.
_, rema... | def upload_string(to_upload, media_type=None, keep_open=False, wait_on_close=False, **kwargs) | :param to_upload: String to upload into a file
:type to_upload: string
:param media_type: Internet Media Type
:type media_type: string
:param keep_open: If False, closes the file after uploading
:type keep_open: boolean
:param wait_on_close: If True, waits for the file to close
:type wait_on... | 7.82231 | 7.588645 | 1.030791 |
'''
:param project: Project ID to use as context for the listing
:type project: string
:param path: Subtree root path
:type path: string
:param recurse: Return a complete subfolders tree
:type recurse: boolean
Returns a list of subfolders for the remote *path* (included to the result) o... | def list_subfolders(project, path, recurse=True) | :param project: Project ID to use as context for the listing
:type project: string
:param path: Subtree root path
:type path: string
:param recurse: Return a complete subfolders tree
:type recurse: boolean
Returns a list of subfolders for the remote *path* (included to the result) of the *proje... | 5.02452 | 2.441609 | 2.057873 |
# TODO: use Gentoo or deb buildsystem
config_script = os.path.join(src_dir, "configure")
if os.path.isfile(config_script) and os.access(config_script, os.X_OK):
logger.debug("Running ./configure in {cwd}".format(cwd=os.path.abspath(src_dir)))
try:
subprocess.check_call([conf... | def build(src_dir, parallel_build=True) | Runs any build scripts that are found in the specified directory.
In particular, runs ``./configure`` if it exists, followed by ``make -jN``
if it exists (building with as many parallel tasks as there are CPUs on the
system). | 2.201389 | 2.126814 | 1.035064 |
is_local=(not os.path.isabs(link_target))
if is_local:
# make sure that the path NEVER extends outside the resources directory!
d,l = os.path.split(link_target)
link_parts = []
while l:
link_parts.append(l)
d,l = os.path.split(d)
curr_path = ... | def is_link_local(link_target) | :param link_target: The target of a symbolic link, as given by os.readlink()
:type link_target: string
:returns: A boolean indicating the link is local to the current directory.
This is defined to mean that os.path.isabs(link_target) == False
and the link NEVER references the parent ... | 3.641354 | 3.952891 | 0.921188 |
ret_perm = perm_obj | stat.S_IROTH | stat.S_IRGRP | stat.S_IRUSR
if ret_perm & stat.S_IXUSR:
ret_perm = ret_perm | stat.S_IXGRP | stat.S_IXOTH
return ret_perm | def _fix_perms(perm_obj) | :param perm_obj: A permissions object, as given by os.stat()
:type perm_obj: integer
:returns: A permissions object that is the result of "chmod a+rX" on the
given permission object. This is defined to be the permission object
bitwise or-ed with all stat.S_IR*, and if the stat.S_IXU... | 2.521621 | 2.508925 | 1.00506 |
# This has a race condition since the app could have been created or
# published since we last looked.
try:
app_id = dxpy.api.app_new(app_spec)["id"]
return app_id
except dxpy.exceptions.DXAPIError as e:
# TODO: detect this error more reliably
if e.name == 'InvalidIn... | def _create_or_update_version(app_name, version, app_spec, try_update=True) | Creates a new version of the app. Returns an app_id, or None if the app has
already been created and published. | 4.985049 | 4.728847 | 1.054179 |
if not try_update:
return None
try:
app_id = dxpy.api.app_update("app-" + app_name, version, app_spec)["id"]
return app_id
except dxpy.exceptions.DXAPIError as e:
if e.name == 'InvalidState':
print('App %s/%s has already been published' % (app_spec["name"], v... | def _update_version(app_name, version, app_spec, try_update=True) | Updates a version of the app in place. Returns an app_id, or None if the
app has already been published. | 3.234485 | 2.81448 | 1.14923 |
return _create_app(dict(regionalOptions=regional_options), app_name, src_dir, publish=publish,
set_default=set_default, billTo=billTo, try_versions=try_versions, try_update=try_update,
confirm=confirm) | def create_app_multi_region(regional_options, app_name, src_dir, publish=False, set_default=False, billTo=None,
try_versions=None, try_update=True, confirm=True) | Creates a new app object from the specified applet(s).
:param regional_options: Region-specific options for the app. See
https://wiki.dnanexus.com/API-Specification-v1.0.0/Apps#API-method:-/app/new
for details; this should contain keys for each region the app is
to be enabled in, and for th... | 1.86947 | 2.499772 | 0.747856 |
# In this case we don't know the region of the applet, so we use the
# legacy API {"applet": applet_id} without specifying a region
# specifically.
return _create_app(dict(applet=applet_id), applet_name, src_dir, publish=publish, set_default=set_default,
billTo=billTo, try_ve... | def create_app(applet_id, applet_name, src_dir, publish=False, set_default=False, billTo=None, try_versions=None,
try_update=True, confirm=True, regional_options=None) | Creates a new app object from the specified applet.
.. deprecated:: 0.204.0
Use :func:`create_app_multi_region()` instead. | 3.68574 | 3.768802 | 0.977961 |
enabled_regions = dxpy.executable_builder.get_enabled_regions('app', app_spec, from_command_line, AppBuilderException)
if enabled_regions is not None and len(enabled_regions) == 0:
raise AssertionError("This app should be enabled in at least one region")
return enabled_regions | def get_enabled_regions(app_spec, from_command_line) | Returns a list of the regions in which the app should be enabled.
Also validates that app_spec['regionalOptions'], if supplied, is
well-formed.
:param app_spec: app specification
:type app_spec: dict
:param from_command_line: The regions specified on the command-line
via --region
:type f... | 5.098403 | 6.353869 | 0.802409 |
'''
:param msg: string message to print before exiting
Print the error message, as well as a blurb on where to find the
job workspaces
'''
msg += '\n'
msg += 'Local job workspaces can be found in: ' + str(environ.get('DX_TEST_JOB_HOMEDIRS'))
sys.exit(msg) | def exit_with_error(msg) | :param msg: string message to print before exiting
Print the error message, as well as a blurb on where to find the
job workspaces | 12.096168 | 4.320843 | 2.799492 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.