Diracclient
Classes¶
DiracClient ¶
DiracClient(
rucio_host=None,
auth_host=None,
account=None,
ca_cert=None,
auth_type=None,
creds=None,
timeout=600,
user_agent="rucio-clients",
vo=None,
logger=LOG,
)
Client for the DIRAC integration layer.
This client wraps the REST calls used by the RucioFileCatalog
plugin in DIRAC.
Only add_files
is currently provided and it behaves like any other BaseClient
method by handling authentication tokens and host selection automatically.
Functions¶
add_files ¶
add_files(
lfns, ignore_availability=False, parents_metadata=None
)
Register files and create missing parent structures.
For each entry in lfns
the method:
- Creates the file and its replica on the specified RSE.
- If the containing dataset does not exist, it is created with a replication
rule using the RSE expression
ANY=true
. This places the dataset on any RSE advertising theANY
attribute. - Creates all ancestor containers when needed.
- Attaches metadata from
parents_metadata
to those parents.
PARAMETER | DESCRIPTION |
---|---|
lfns
|
Iterable of dictionaries describing the files. Each dictionary must contain:
Optional keys include
TYPE:
|
ignore_availability
|
When
TYPE:
|
parents_metadata
|
Mapping of parent logical path names to metadata {'lpn': {key : value}}. Entries are only applied when new datasets or containers are created. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Literal[True]
|
When the server confirms the creation. |
RAISES | DESCRIPTION |
---|---|
RucioException
|
Raised when the HTTP request is not successful. |
Examples:
Example
Register a file using the DIRAC naming style. Dirac's scope extraction is required to be set for this to work:
>>> from rucio.client.diracclient import DiracClient
>>> from rucio.common.utils import generate_uuid
>>> dc = DiracClient()
>>> lfn = f"/belle/mock/cont_{generate_uuid()}/dataset_{generate_uuid()}/file_{generate_uuid()}"
>>> files = [{
... "lfn": lfn,
... "rse": "XRD1",
... "bytes": 1,
... "adler32": "0cc737eb",
... 'guid': generate_uuid()
... }]
>>> dc.add_files(files)
True