py4cytoscape.sandbox.sandbox_set
-
sandbox_set
(sandbox_name, copy_samples=True, reinitialize=True, base_url='http://127.0.0.1:1234/v1')[source] Set a new default sandbox, creating it if necessary.
A sandbox is the root for the file system used for all file operations. When running a workflow from a command line or notebook on the same workstation as Cytoscape, the default sandbox is the entire workstation file system, and the current directory is the same as the Python kernel’s default directory. When running a workflow on a remote server, the default sandbox is the ‘default_sandbox’ created automatically under the under the
filetransfer
directory in the CytoscapeConfiguration directory. Naming a custom sandbox with this sandbox_set() function creates a new sub-directory as a sibling to ‘default_sandbox’ and uses it for subsequent file operations. Setting a None sandbox reverts to the workstation’s file system when the workflow is running on the Cytoscape workstation, and ‘default_sandbox’ when the workflow is running remotely.Sandboxes are highly recommended as an aid to creating workflows that can be shared with others.
- Parameters
sandbox_name (str) – Name of new default sandbox. None means to use the original default sandbox (e.g., the whole file system for local execution, or ‘default_sandbox’ for remote execution). If new sandbox doesn’t exist, it is created.
copy_samples (bool) – True to copy the Cytoscape sampleData into the sandbox
reinitialize (bool) – True to delete sandbox contents (if any) if sandbox already exists
base_url (str) – Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://localhost:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.
- Returns
sandbox path in Cytoscape workstation’s file system
- Return type
str
- Raises
CyError – if sandbox_name is invalid or sandbox can’t be created
requests.exceptions.HTTPError – if can’t connect to Cytoscape, Cytoscape returns an error, or sandbox can’t be created
Examples
>>> sandbox_set(None) # When running on the Cytoscape workstation 'C:\Users\CyDeveloper\PycharmProjects\py4cytoscape\tests\scratchpad' >>> sandbox_set(None) # When running on on a remote server 'C:\Users\CyDeveloper\CytoscapeConfiguration\filetransfer\default_sandbox' >>> sandbox_set('mySand', copy_samples=False, reinitialize=False) # Keep prior sandbox contents 'C:\Users\CyDeveloper\CytoscapeConfiguration\filetransfer\mySand'
See also
Sandboxing in the Concepts section in the py4cytoscape User Manual.