Skip to content

Commit

Permalink
Merge pull request #7619 from chaen/cherry-pick-2-c111713c2-integration
Browse files Browse the repository at this point in the history
[sweep:integration] feat (FTS3): prepare for breaking API release
  • Loading branch information
fstagni authored May 16, 2024
2 parents df16ef4 + 6a5c50e commit 4a48b8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion docs/diracdoctools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"arc",
"cmreslogging",
"diracx",
"fts3",
"gfal2",
"git",
"lcg_util",
Expand Down
19 changes: 17 additions & 2 deletions src/DIRAC/DataManagementSystem/Client/FTS3Job.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
""" FTS3Job module containing only the FTS3Job class """

import datetime
import errno
from packaging.version import Version


# Requires at least version 3.3.3
from fts3 import __version__ as fts3_version
import fts3.rest.client.easy as fts3
from fts3.rest.client.exceptions import FTS3ClientException, NotFound

# There is a breaking change in the API in 3.13
# https://gitlab.cern.ch/fts/fts-rest-flask/-/commit/5faa283e0cd4b80a0139a547c4a6356522c8449d
FTS3_SPACETOKEN_API_CHANGE = Version("3.13")
if Version(fts3_version) >= FTS3_SPACETOKEN_API_CHANGE:
DESTINATION_SPACETOKEN_ATTR = "destination_spacetoken"
else:
DESTINATION_SPACETOKEN_ATTR = "spacetoken"

# We specifically use Request in the FTS client because of a leak in the
# default pycurl. See https://its.cern.ch/jira/browse/FTS-261
from fts3.rest.client.request import Request as ftsSSLRequest
Expand Down Expand Up @@ -501,11 +513,11 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N
if self.activity:
job_metadata["activity"] = self.activity

dest_spacetoken = {DESTINATION_SPACETOKEN_ATTR: target_spacetoken}
job = fts3.new_job(
transfers=transfers,
overwrite=True,
source_spacetoken=source_spacetoken,
spacetoken=target_spacetoken,
bring_online=bring_online,
copy_pin_lifetime=copy_pin_lifetime,
retry=3,
Expand All @@ -514,6 +526,7 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N
metadata=job_metadata,
priority=self.priority,
archive_timeout=archive_timeout,
**dest_spacetoken,
)

return S_OK((job, fileIDsInTheJob))
Expand Down Expand Up @@ -641,16 +654,18 @@ def _constructStagingJob(self, pinTime, allLFNs, target_spacetoken):
if self.activity:
job_metadata["activity"] = self.activity

dest_spacetoken = {DESTINATION_SPACETOKEN_ATTR: target_spacetoken}

job = fts3.new_job(
transfers=transfers,
overwrite=True,
source_spacetoken=target_spacetoken,
spacetoken=target_spacetoken,
bring_online=bring_online,
copy_pin_lifetime=copy_pin_lifetime,
retry=3,
metadata=job_metadata,
priority=self.priority,
**dest_spacetoken,
)

return S_OK((job, fileIDsInTheJob))
Expand Down

0 comments on commit 4a48b8c

Please sign in to comment.