py4cytoscape.sandbox.sandbox_send_to

sandbox_send_to(source_file, dest_file=None, overwrite=True, sandbox_name=None, base_url='http://127.0.0.1:1234/v1')[source]

Transfer a file to a sandbox.

The source file is transferred to the named (or current) sandbox, overwriting an existing file if one already exists. The dest_file can be an absolute path if the sandbox is the entire file system (i.e., for standalone Python execution) or a path relative to the sandbox (i.e., for Notebook or remote execution or if a sandbox was explicitly created).

Note that there is no function that transfers an entire directory. Note, though, that when using sandbox_set() to make a sandbox current, it is possible to copy the Cytoscape sample data directories into to the sandbox at the same time.

Parameters
  • source_file (str) – Name of file in the Python workflow’s file system

  • dest_file (str) – Name of file to write (as absolute path or sandbox-relative path) … if None, use file name in source_file

  • overwrite (bool) – False causes error if dest_file already exists; True replaces it if it exists

  • sandbox_name (str) – Name of sandbox containing file. None means “the current sandbox”.

  • 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

{‘filePath’: <new file’s absolute path in Cytoscape workstation>}

Return type

dict

Raises
  • CyError – if file name is invalid

  • requests.exceptions.HTTPError – if can’t connect to Cytoscape, Cytoscape returns an error, or sandbox is invalid

Examples

>>> sandbox_send_to('myData.csv')
{'filePath': 'C:\Users\CyDeveloper\CytoscapeConfiguration\filetransfer\default_sandbox\myData.csv'}
>>> sandbox_send_to('myData01.csv', 'myData.csv', overwrite=True)
{'filePath': 'C:\Users\CyDeveloper\CytoscapeConfiguration\filetransfer\default_sandbox\myData.csv'}
>>> sandbox_send_to('myData01.csv', 'myData.csv', sandbox_name='mySand')
{'filePath': 'C:\Users\CyDeveloper\CytoscapeConfiguration\filetransfer\mySand\myData.csv'}

See also

Sandboxing in the Concepts section in the py4cytoscape User Manual.