18 from io
import StringIO
34 if 'SAM_EXPERIMENT' in os.environ:
35 exp = os.environ[
'SAM_EXPERIMENT']
36 samweb = samweb_cli.SAMWebClient(experiment=exp)
38 md = samweb.getMetadata(filenameorid=filename)
49 file_type = md[
'file_type']
53 data_tier = md[
'data_tier']
55 if not file_type
or not group
or not data_tier:
57 'Missing or invalid metadata for file %s.' % filename)
62 if 'FTS_DROPBOX' in os.environ:
63 dropbox_root = os.environ[
'FTS_DROPBOX']
65 dropbox_root =
'/pnfs/sbnd/scratch/sbndpro/dropbox'
66 path =
'%s/%s/%s/%s' % (dropbox_root, file_type, group, data_tier)
73 result =
'services.FileCatalogMetadataSBN: {\n'
75 result = result +
' FCLName: "%s"\n' % os.path.basename(stage.fclname)
77 result = result +
' FCLName: "'
78 for fcl
in stage.fclname:
79 result = result +
'%s/' % os.path.basename(fcl)
81 result = result +
'"\n'
82 result = result +
' FCLVersion: "%s"\n' % project.release_tag
83 result = result +
' ProjectName: "%s"\n' % project.name
84 result = result +
' ProjectStage: "%s"\n' % stage.name
85 result = result +
' ProjectVersion: "%s"\n' % project.release_tag
86 result = result +
'}\n'
95 CVMFS_DIR =
"/cvmfs/sbnd.opensciencegrid.org/products/sbnd/"
96 FERMIAPP_DIR =
"/grid/fermiapp/products/sbnd/"
98 if os.path.isfile(FERMIAPP_DIR+
"setup_sbnd.sh"):
99 setup_script = FERMIAPP_DIR+
"setup_sbnd.sh"
100 elif os.path.isfile(CVMFS_DIR+
"setup_sbnd.sh"):
101 setup_script = CVMFS_DIR+
"setup_sbnd.sh"
103 raise RuntimeError(
"Could not find setup script at " +
104 FERMIAPP_DIR+
" or "+CVMFS_DIR)
115 data_tier = stage.ana_data_tier
117 data_tier = stage.data_tier
118 dim =
'file_type %s' % project.file_type
119 dim = dim +
' and data_tier %s' % data_tier
120 dim = dim +
' and ub_project.name %s' % project.name
121 dim = dim +
' and ub_project.stage %s' % stage.name
122 dim = dim +
' and ub_project.version %s' % project.release_tag
123 if stage.pubs_output:
125 for subrun
in stage.output_subruns:
128 ' and run_number %d.%d' % (stage.output_run, subrun)
133 if stage.output_run > 1
and stage.output_run < 100:
134 dim = dim +
',1.%d' % subrun
136 dim = dim +
',%d.%d' % (stage.output_run, subrun)
137 elif project.run_number != 0:
138 dim = dim +
' and run_number %d' % project.run_number
139 dim = dim +
' and availability: anylocation'
def get_setup_script_path