Skip to content

Commit

Permalink
try rewriting files using iceprod plugin instead of prearg
Browse files Browse the repository at this point in the history
  • Loading branch information
dsschult committed Oct 7, 2024
1 parent bed40df commit 7accf24
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 0 additions & 1 deletion iceprod/server/data/condor_transfer_plugins/gsiftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
EXIT_AUTHENTICATION_REFRESH = 2
EXIT_IMPORT_ERROR = 3

try:
from classad import ClassAd, parseAds
Expand Down
17 changes: 16 additions & 1 deletion iceprod/server/data/condor_transfer_plugins/iceprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,35 @@ def get_error_dict(error, url=''):
class IceProdPlugin:

def setup_env(self):
# if an X509 proxy exists, use it for GridFTP
# if a proxy exists, use it
proxies = glob.glob(os.path.join(os.getcwd(), 'x509up_*'))
if proxies:
os.environ['X509_USER_PROXY'] = proxies[0]
else:
raise RuntimeError('X509_USER_PROXY does not exist')

if not os.path.exists('/cvmfs/icecube.opensciencegrid.org/iceprod/v2.7.1/env-shell.sh'):
raise RuntimeError('CVMFS does not exist')

def _split_url(self, url):
# strip off iceprod:// prefix
url = url[10:]
# split url
method = url.split('://')[0]
transfer = 'true'
mapping = None
if '-' in method:
transfer, method = method.split('-',1)
url = url.split('-',1)[-1]
if '?' in url:
url, args = url.split('?',1)
args = {x.split('=')[0]: x.split('=',1)[-1] for x in args[1:].split('&')}
mapping = args.get('mapping')
return {
'method': method,
'url': url,
'transfer': transfer,
'mapping': mapping,
}

def _do_globus_transfer(self, inpath, outpath):
Expand Down Expand Up @@ -189,6 +200,7 @@ def download_file(self, url, local_file_path):
url = ret['url']
method = ret['method']
transfer = ret['transfer']
mapping = ret['mapping']

if transfer in ('true', 'maybe'):
if method == 'gsiftp':
Expand Down Expand Up @@ -223,6 +235,9 @@ def download_file(self, url, local_file_path):
else:
raise Exception('unknown protocol "{0}"'.format(method))

if mapping and os.path.exists(local_file_path):
os.symlink(local_file_path, mapping)

end_time = time.time()

# Get transfer statistics
Expand Down
5 changes: 3 additions & 2 deletions iceprod/server/plugins/condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@ def condor_infiles(self, infiles):
if infile.transfer == Transfer.MAYBE:
url = 'iceprod://maybe-' + infile.url
else:
url = infile.url
url = 'iceprod://true-' + infile.url
files.append(url)
basename = Path(infile.url).name
if basename != infile.local:
mapping.append((basename,infile.local))
url += '?mapping='+infile.local
#mapping.append((basename,infile.local))
ads = {}
if mapping:
ads['PreCmd'] = f'"{self.precmd.name}"'
Expand Down
5 changes: 3 additions & 2 deletions tests/server/plugins/condor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_CondorSubmit_condor_infiles(schedd):
]

ret = sub.condor_infiles(infiles)
assert ret['transfer_input_files'] == ['http://foo.test/foo']
assert ret['transfer_input_files'] == ['iceprod://true-http://foo.test/foo']
assert 'PreCmd' not in ret


Expand Down Expand Up @@ -134,10 +134,11 @@ def test_CondorSubmit_condor_infiles_gsiftp(schedd):
cfg['queue']['x509proxy'] = '/tmp/x509'

ret = sub.condor_infiles(infiles)
assert ret['transfer_input_files'] == ['/tmp/x509', 'gsiftp://foo.test/foo']
assert ret['transfer_input_files'] == ['/tmp/x509', 'iceprod://true-gsiftp://foo.test/foo']
assert 'PreCmd' not in ret


@pytest.mark.skip
def test_CondorSubmit_condor_precmd(schedd, i3prod_path):
logging.info('cfgfile: %r', os.path.exists(os.path.expandvars('$I3PROD/etc/iceprod_config.json')))
override = ['queue.type=condor']
Expand Down

0 comments on commit 7accf24

Please sign in to comment.