Classes | Functions
experiment_utilities Namespace Reference

Classes

class  MetaDataKey
 

Functions

def get_dropbox (filename)
 
def get_sam_metadata (project, stage)
 
def get_ups_products ()
 
def get_setup_script_path ()
 
def dimensions (project, stage, ana=False)
 
def get_proxy ()
 

Function Documentation

def experiment_utilities.dimensions (   project,
  stage,
  ana = False 
)

Definition at line 86 of file experiment_utilities.py.

86 def dimensions(project, stage, ana=False):
87 
88  dim = 'file_type %s' % project.file_type
89  dim = dim + ' and data_tier %s' % stage.data_tier
90  for key in project.parameters:
91  if key == 'MCName':
92  dim = dim + ' and lbne_MC.name %s' % project.parameters[key]
93  if key == 'DataName':
94  dim = dim + ' and lbne_data.name %s' % project.parameters[key]
95  dim = dim + ' and version %s' % project.release_tag
96  dim = dim + ' and application %s' % stage.name
97  dim = dim + ' and availability: anylocation'
98  return dim
99 
100 # Get grid proxy.
101 
def dimensions(project, stage, ana=False)
def experiment_utilities.get_dropbox (   filename)

Definition at line 25 of file experiment_utilities.py.

25 def get_dropbox(filename):
26 
27  # Get metadata.
28 
29  md = {}
30  exp = 'dune'
31  if os.environ.has_key('SAM_EXPERIMENT'):
32  exp = os.environ['SAM_EXPERIMENT']
33  samweb = samweb_cli.SAMWebClient(experiment=exp)
34  try:
35  md = samweb.getMetadata(filenameorid=filename)
36  except:
37  pass
38 
39  # Extract the metadata fields that we need.
40 
41  file_type = ''
42 
43  if md.has_key('file_type'):
44  file_type = md['file_type']
45 
46  if not file_type:
47  raise RuntimeError('Missing or invalid metadata for file %s.' % filename)
48 
49  # Construct dropbox path.
50 
51  #path = '/dune/data/dunepro/dropbox/%s' % file_type
52  path = '/pnfs/dune/scratch/dunepro/dropbox/%s' % file_type
53  return path
54 
55 # Return fcl configuration for experiment-specific sam metadata.
56 
def experiment_utilities.get_proxy ( )

Definition at line 102 of file experiment_utilities.py.

102 def get_proxy():
103 
104  global proxy_ok
105  proxy_ok = False
106 
107  # Make sure we have a valid certificate.
108 
109  larbatch_utilities.test_kca()
110 
111  # Get proxy using either specified cert+key or default cert.
112 
113  if os.environ.has_key('X509_USER_CERT') and os.environ.has_key('X509_USER_KEY'):
114  cmd=['voms-proxy-init',
115  '-rfc',
116  '-cert', os.environ['X509_USER_CERT'],
117  '-key', os.environ['X509_USER_KEY'],
118  '-voms', '%s:/%s/Role=%s' % (larbatch_utilities.get_experiment(), larbatch_utilities.get_experiment(), larbatch_utilities.get_role())]
119  try:
120  subprocess.check_call(cmd, stdout=-1, stderr=-1)
121  proxy_ok = True
122  except:
123  pass
124  pass
125  else:
126  cmd=['voms-proxy-init',
127  '-noregen',
128  '-rfc',
129  '-voms',
130  '%s:/%s/Role=%s' % (larbatch_utilities.get_experiment(), larbatch_utilities.get_experiment(), larbatch_utilities.get_role())]
131  jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE,
132  stderr=subprocess.PIPE)
133  jobout, joberr = jobinfo.communicate()
134  rc = jobinfo.poll()
135  if rc != 0 and rc!= 1:
136  proxy_ok = False
137  else:
138  proxy_ok = True
139  # Done
140 
141  return proxy_ok
142 
def experiment_utilities.get_sam_metadata (   project,
  stage 
)

Definition at line 57 of file experiment_utilities.py.

57 def get_sam_metadata(project, stage):
58  result = 'services.FileCatalogMetadataDUNE: {\n'
59  for key in project.parameters:
60  result = result + ' %s: "%s"\n' % (key, project.parameters[key])
61  for key in stage.parameters:
62  result = result + ' %s: "%s"\n' % (key, stage.parameters[key])
63  result = result + ' StageName: "%s"\n' % stage.name
64  result = result + '}\n'
65  result = result + 'services.TFileMetadataDUNE: @local::dune_tfile_metadata\n'
66  return result
67 
def get_sam_metadata(project, stage)
def experiment_utilities.get_setup_script_path ( )

Definition at line 73 of file experiment_utilities.py.

74 
75  OASIS_DIR="/cvmfs/dune.opensciencegrid.org/products/dune/"
76 
77  if os.path.isfile(OASIS_DIR+"setup_dune.sh"):
78  setup_script = OASIS_DIR+"setup_dune.sh"
79  else:
80  raise RuntimeError("Could not find setup script at "+OASIS_DIR)
81 
82  return setup_script
83 
84 # Construct dimension string for project, stage.
85 
def experiment_utilities.get_ups_products ( )

Definition at line 68 of file experiment_utilities.py.

69  return 'dunetpc'
70 
71 # Function to return path to the setup_dune.sh script
72