This Python 2.7 package includes three key modules:
It has the following external dependencies:
When this package is imported, configuration values will be loaded from the following sources in order of decreasing priority:
The bindings are configured by the following environment variables:
A JSON hash containing your auth token, typically of the form {"auth_token_type": "Bearer", "auth_token": "YOUR_TOKEN"}.
Either http or https (usually https).
Hostname of the DNAnexus API server.
Port of the DNAnexus API server.
Should only be present if run in an Execution Environment; indicates the ID of the currently running job.
Should only be present if run in an Execution Environment; indicates the running job’s temporary workspace ID.
Indicates either the project context of a running job, or the default project to use for a user accessing the platform from the outside.
The following fields can be used to read the current configuration values:
Protocol being used to access the DNAnexus API server. Either http or https (usually https).
Hostname of the DNAnexus API server.
Port of the DNAnexus API server.
Indicates the ID of the currently running job, or None if we are not in an Execution Environment.
Indicates the temporary workspace ID of the currently running job, or the current project if we are not in an Execution Environment.
Indicates either the project context of a running job, if there is one, or the default project that is being used, for users accessing the platform from the outside.
The user agent string that dxpy will send to the server with each request.
The dxpy.DXHTTPRequest() function uses the DX_SECURITY_CONTEXT and DX_APISERVER_* variables to select an API server and provide appropriate authentication headers to it. (Note: all methods in the dxpy.api module, and by extension any of the bindings methods that make API calls, use this function.)
All object handler methods that require a project or data container ID use by default the DX_WORKSPACE_ID (if running inside an Execution Environment) or DX_PROJECT_CONTEXT_ID (otherwise).
The following functions can be used to override any of the settings obtained from the environment for the duration of the session:
To pass API server requests through an HTTP(S) proxy, set the following environment variables:
HTTP proxy, in the form ‘protocol://hostname:port’ (e.g. ‘http://10.10.1.10:3128’)
HTTPS proxy, in the form ‘protocol://hostname:port’
Parameters: |
|
---|---|
Returns: | Response from API server in the format indicated by want_full_response and decode_response_body. |
Raises: | exceptions.DXAPIError or a subclass if the server returned a non-200 status code; requests.exceptions.HTTPError if an invalid response was received from the server; or requests.exceptions.ConnectionError if a connection cannot be established. |
Wrapper around requests.request() that makes an HTTP request, inserting authentication headers and (by default) converting data to JSON.
Note
Bindings methods that make API calls make the underlying HTTP request(s) using DXHTTPRequest(), and most of them will pass any unrecognized keyword arguments you have supplied through to DXHTTPRequest().
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.
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).
Parameters: |
|
---|
Overrides the current settings for which API server to communicate with. Any parameters that are not explicitly specified are not overridden.
Parameters: | dxid (string) – ID of a job |
---|
Sets the ID of the running job.
Warning
This function is only really useful if you are developing code that will run in and interact with the Execution Environment, but wish to test it outside of an actual Execution Environment.
Parameters: | dxid (string) – Project ID |
---|
Sets the project context for a running job.
Warning
This function is only really useful if you are developing code that will run in and interact with the Execution Environment but wish to test it outside of an actual Execution Environment.
It does not change the default data container in which new objects are created or name resolution is performed. If you want to do that, use set_workspace_id() instead.
Parameters: | security_context (dict) – Authentication hash, usually with keys auth_token_type set to Bearer and auth_token set to the authentication token. |
---|
Sets the security context to use the provided token.
Parameters: | port (string) – port to use for streaming job logs |
---|
Sets the port to use for streaming job logs via dx watch inside the Execution Environment
Warning
This function is only really useful if you are developing code that will run in and interact with the Execution Environment.