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 standalone on the same workstation as Cytoscape, the default sandbox is the directory that’s current for the Python kernel. When running in a Notebook or remote server, the default sandbox is the ‘default_sandbox’ created automatically under the under the filetransfer directory in the CytoscapeConfiguration directory. Naming a sandbox with this function creates a new sub-directory as a sibling to ‘default_sandbox’ and uses it for subsequent file operations. Setting a None sandbox uses the default sandbox instead.

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 Notebook and 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 standalone on the Cytoscape workstation
'C:\Program Files\Cytoscape_v3.8.1'
>>> sandbox_set(None) # When running in a Notebook
'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.