All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
experiment_utilities Namespace Reference

Functions

def get_dropbox
 
def get_sam_metadata
 
def get_setup_script_path
 
def dimensions
 
def get_ups_products
 

Function Documentation

def experiment_utilities.dimensions (   project,
  stage 
)

Definition at line 111 of file experiment_utilities.py.

112 def dimensions(project, stage):
113 
114  data_tier = ''
115  if ana:
116  data_tier = stage.ana_data_tier
117  else:
118  data_tier = stage.data_tier
119  dim = 'file_type %s' % project.file_type
120  dim = dim + ' and data_tier %s' % data_tier
121  dim = dim + ' and ub_project.name %s' % project.name
122  dim = dim + ' and ub_project.stage %s' % stage.name
123  dim = dim + ' and ub_project.version %s' % project.release_tag
124  if stage.pubs_output:
125  first_subrun = True
126  for subrun in stage.output_subruns:
127  if first_subrun:
128  dim = dim + \
129  ' and run_number %d.%d' % (stage.output_run, subrun)
130  first_subrun = False
131 
132  # Kluge to pick up mc files with wrong run number.
133 
134  if stage.output_run > 1 and stage.output_run < 100:
135  dim = dim + ',1.%d' % subrun
136  else:
137  dim = dim + ',%d.%d' % (stage.output_run, subrun)
138  elif project.run_number != 0:
139  dim = dim + ' and run_number %d' % project.run_number
140  dim = dim + ' and availability: anylocation'
141  return dim
142 
def experiment_utilities.get_dropbox (   filename)

Definition at line 28 of file experiment_utilities.py.

28 
29 def get_dropbox(filename):
30 
31  # Get metadata.
32 
33  md = {}
34  exp = 'sbnd'
35  if 'SAM_EXPERIMENT' in os.environ:
36  exp = os.environ['SAM_EXPERIMENT']
37  samweb = samweb_cli.SAMWebClient(experiment=exp)
38  try:
39  md = samweb.getMetadata(filenameorid=filename)
40  except:
41  pass
42 
43  # Extract the metadata fields that we need.
44 
45  file_type = ''
46  group = ''
47  data_tier = ''
48 
49  if 'file_type' in md:
50  file_type = md['file_type']
51  if 'group' in md:
52  group = md['group']
53  if 'data_tier' in md:
54  data_tier = md['data_tier']
55 
56  if not file_type or not group or not data_tier:
57  raise RuntimeError(
58  'Missing or invalid metadata for file %s.' % filename)
59 
60  # Construct dropbox path.
61 
62  #path = '/sbnd/data/sbndsoft/dropbox/%s/%s/%s' % (file_type, group, data_tier)
63  if 'FTS_DROPBOX' in os.environ:
64  dropbox_root = os.environ['FTS_DROPBOX']
65  else:
66  dropbox_root = '/pnfs/sbnd/scratch/sbndpro/dropbox'
67  path = '%s/%s/%s/%s' % (dropbox_root, file_type, group, data_tier)
68  return path
69 
70 # Return fcl configuration for experiment-specific sam metadata.
71 
def experiment_utilities.get_sam_metadata (   project,
  stage 
)

Definition at line 72 of file experiment_utilities.py.

72 
73 def get_sam_metadata(project, stage):
74  result = 'services.FileCatalogMetadataSBN: {\n'
75  if type(stage.fclname) == type('') or type(stage.fclname) == type(''):
76  result = result + ' FCLName: "%s"\n' % os.path.basename(stage.fclname)
77  else:
78  result = result + ' FCLName: "'
79  for fcl in stage.fclname:
80  result = result + '%s/' % os.path.basename(fcl)
81  result = result[:-1]
82  result = result + '"\n'
83  result = result + ' FCLVersion: "%s"\n' % project.release_tag
84  result = result + ' ProjectName: "%s"\n' % project.name
85  result = result + ' ProjectStage: "%s"\n' % stage.name
86  result = result + ' ProjectVersion: "%s"\n' % project.release_tag
87  result = result + '}\n'
88 
89  return result
90 
91 # Function to return path to the setup_sbnd.sh script
92 
def experiment_utilities.get_setup_script_path ( )

Definition at line 93 of file experiment_utilities.py.

93 
95 
96  CVMFS_DIR = "/cvmfs/sbnd.opensciencegrid.org/products/sbnd/"
97  FERMIAPP_DIR = "/grid/fermiapp/products/sbnd/"
98 
99  if os.path.isfile(FERMIAPP_DIR+"setup_sbnd.sh"):
100  setup_script = FERMIAPP_DIR+"setup_sbnd.sh"
101  elif os.path.isfile(CVMFS_DIR+"setup_sbnd.sh"):
102  setup_script = CVMFS_DIR+"setup_sbnd.sh"
103  else:
104  raise RuntimeError("Could not find setup script at " +
105  FERMIAPP_DIR+" or "+CVMFS_DIR)
106 
107  return setup_script
108 
109 # Construct dimension string for project, stage.
110 
def experiment_utilities.get_ups_products ( )

Definition at line 143 of file experiment_utilities.py.

144 def get_ups_products():
145  return 'sbndcode'