Python API: sam v8_1_5 sam.getDestination()
|  |
This is the python interface to the command 'sam get destination'.
Command Description:
This command returns the appropriate path wherein a file should
be stored in the Fermilab enstore robot, based on the file
metadata, the work group under which the file will be stored,
and the Experiment's configuration of the Autodest server.
For files which have not yet been declared to SAM, you must include
either a metadata description file and its path (CLI) or a SamDataFile object
(API) so that "get destination" can calculate the path.
sam get destination --descriptionFile=/full/path/to/myMetadata.py
The metadata description file must contain one SamDataFile object which
describes the metadata to be entered into the database:
# myMetadata.py:
from SamFile.SamDataFile import SamDataFile
myMetadata = SamDataFile(fileName='raw_physics_file_name_here',
fileType='importedCollider',
group='my_physics_group_here',
...)
You may also get the destination for files which have already been
declared to SAM, using the --fileName or --fileId options:
sam get destination --fileName=myFileNameAlreadyDeclaredInSam
sam get destination --fileId=10001
In the API, you may pass in a metadata object rather than a
description file:
myMetadata = SamDataFile(fileName='raw_physics_file_name_here',
fileType='importedCollider',
group='my_physics_group',
...}
sam.getDestination(metadata=myMetadata)
Or, you may pass in the fileName or fileId of a file that has
already been declared to SAM:
sam.getDestination(fileName='existing_data_file_name')
sam.getDestination(fileId=12345)
For additional information about file metadata, see the output
from the commands:
sam get registered filetypes
sam describe metadata requirements --filetype=<fileTypeHere>
sam describe metadata attributes
Python Usage:
from Sam import sam
result = sam.getDestination(...)
Return value: SamStruct.NameOrId.NameOrId
Arguments are passed as keyword-value pairs, as in:
myfunc(arg1='myarg', arg2='anotherarg', d=1)
Argument Keyword Description:
(*) indicates that this keyword is required
>>> indicates that either the API object or the CLI equivalent (<<<) is required
====================================================================================================================================
KEYWORD DATA TYPE DESCRIPTION
------------------------------------------------------------------------------------------------------------------------------------
c SamBoolean automatically close all servants after each method call
corbaCallTimeout int time in seconds for CORBA method calls to return before timing out (default: 0; zero implies no timeout)
d SamBoolean debug mode
<<< descriptionFile string name of the python file containing the metadata for the file
<<< fileId long DB-assigned ID number of the file of interest
<<< fileName string name of the file of interest
>>> metadata SamBoolean SamDataFile object containing the metadata
retryInterval int retry interval base in seconds; will multiply this base times retryCount (default: 5)
retryJitter int retry jitter, random jitter added to base retry interval times retryCount (default: 5)
retryMaxCount int number of times to retry CORBA calls for retriable exceptions (default: 25; zero implies no retries)
s SamBoolean retrySilently mode (do not issue messages to stderr on proxy retries)
t SamBoolean time-it mode (print additional info on timings)
v SamBoolean verbose mode
====================================================================================================================================
Python API-only Keywords:
'metadata': replaces (fileName, fileId, descriptionFile)
Must have at least one of:
(metadata, fileName, fileId, descriptionFile)
Mutually exclusive keywords:
(fileName || fileId || descriptionFile)
Environment Defaults:
c = os.environ['SAM_PYAPI_AUTO_CLOSE_SERVANTS']
corbaCallTimeout = os.environ['SAM_PYAPI_CORBA_CALL_TIMEOUT']
retryInterval = os.environ['SAM_PYAPI_RETRY_INTERVAL']
retryJitter = os.environ['SAM_PYAPI_RETRY_JITTER']
retryMaxCount = os.environ['SAM_PYAPI_RETRY_MAX_COUNT']
s = os.environ['SAM_PYAPI_RETRY_SILENTLY']
See Also: