diff --git a/py/LSS/common_tools.py b/py/LSS/common_tools.py index 85934fff..b68f5fa3 100755 --- a/py/LSS/common_tools.py +++ b/py/LSS/common_tools.py @@ -1855,7 +1855,7 @@ def convert_fits2h5(filename): write_LSShdf5_scratchcp(ff, filename.replace('.fits', '.h5')) -def write_LSShdf5_scratchcp(ff, outf, logger=None): +def write_LSShdf5_scratchcp(ff, outf, logger=None, mode=0o664): import h5py import hdf5plugin # need to be in the cosmodesi test environment, as of Sep 4th 25 @@ -1874,7 +1874,7 @@ def write_LSShdf5_scratchcp(ff, outf, logger=None): rng = np.random.default_rng() # seed=rann) ranstring = int(rng.random()*1e10) tmpfn = os.getenv('SCRATCH')+'/' + \ - outf.split('/')[-1] + '.tmp'+str(ranstring) + os.path.basename(outf) + '.tmp'+str(ranstring) if os.path.isfile(tmpfn): # os.system('rm ' + tmpfn) os.remove(tmpfn) @@ -1897,7 +1897,8 @@ def write_LSShdf5_scratchcp(ff, outf, logger=None): shutil.copy2(tmpfn, outftmp) os.rename(outftmp, outf) # os.system('chmod 775 ' + outf) #this should fix permissions for the group - os.chmod(outf, 0o775) + shutil.chown(outf, group='desi') # essentially chgrp desi. good to ensure at NERSC, but may fail elsewhere, do we need to account for that? + os.chmod(outf, mode) # now that the file's group is desi, could set permissions to 660 for more security printlog('moved output to ' + outf, logger) df = 0 # printlog('checking read of column ' + testcol, logger) @@ -1941,7 +1942,7 @@ def read_hdf5_blosc(filename, columns=None, extname='LSS'): return data -def write_LSS_scratchcp(ff, outf, comments=None, extname='LSS', logger=None): +def write_LSS_scratchcp(ff, outf, comments=None, extname='LSS', logger=None, mode=0o664): ''' ff is the structured array/Table to be written out as an LSS catalog outf is the full path to write out @@ -1953,7 +1954,7 @@ def write_LSS_scratchcp(ff, outf, comments=None, extname='LSS', logger=None): rng = np.random.default_rng() # seed=rann) ranstring = int(rng.random()*1e10) tmpfn = os.getenv('SCRATCH')+'/' + \ - outf.split('/')[-1] + '.tmp'+str(ranstring) + os.path.basename(outf) + '.tmp'+str(ranstring) if os.path.isfile(tmpfn): os.system('rm ' + tmpfn) fd = fitsio.FITS(tmpfn, "rw") @@ -1979,7 +1980,8 @@ def write_LSS_scratchcp(ff, outf, comments=None, extname='LSS', logger=None): shutil.copy2(tmpfn, outftmp) os.rename(outftmp, outf) # os.system('chmod 775 ' + outf) #this should fix permissions for the group - os.chmod(outf, 0o775) + shutil.chown(outf, group='desi') # essentially chgrp desi. good to ensure at NERSC, but may fail elsewhere, do we need to account for that? + os.chmod(outf, mode) # now that the file's group is desi, could set permissions to 660 for more security # os.system('cp ' + tmpfn + ' ' + outf) # os.system('chmod 775 ' + outf) #this should fix permissions for the group