Skip to content

Commit

Permalink
Merge pull request #326 from sarahgaiser/fix-fieldmaps-issue-in-javatool
Browse files Browse the repository at this point in the history
fix fieldmaps issue
  • Loading branch information
JeremyMcCormick authored Nov 30, 2022
2 parents c759ab2 + 74cac4f commit 62f629f
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions python/hpsmc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,22 @@ def config(self, parser):
if os.getenv("CONDITIONS_URL", None) is not None:
self.conditions_url = os.getenv("CONDITIONS_URL", None)
logger.debug('Set CONDITIONS_URL from environment: {}'.format(self.hps_java_bin_jar))
if self.hps_fieldmaps_dir is None:
self.hps_fieldmaps_dir = "{}/share/fieldmap".format(self.hpsmc_dir)
if not os.path.isdir(self.hps_fieldmaps_dir):
raise Exception("The fieldmaps dir does not exist: {}".format(self.hps_fieldmaps_dir))
logger.debug("Using fieldmap dir from install: {}".format(self.hps_fieldmaps_dir))
else:
logger.debug("Using fieldmap dir from config: {}".format(self.hps_fieldmaps_dir))

def required_config(self):
"""!
Return list of required configurations.
Required configurations are: hps_java_bin_jar
Required configurations are: **hps_java_bin_jar**, **hps_fieldmaps_dir**
@retun list of required configurations.
"""
return ['hps_java_bin_jar']
return ['hps_java_bin_jar', 'hps_fieldmaps_dir']

def setup(self):
"""! Setup JobManager component."""
Expand All @@ -254,6 +261,12 @@ def setup(self):
raise Exception("Steering '%s' not found in: %s" % (self.steering, self.steering_files))
self.steering_file = self.steering_files[self.steering]

logger.debug('Creating sym link to fieldmap dir: {}'.format(self.hps_fieldmaps_dir))
if not os.path.islink(os.getcwd() + os.path.sep + "fieldmap"):
os.symlink(self.hps_fieldmaps_dir, "fieldmap")
else:
logger.warning('Link to fieldmap dir already exists!')

def cmd_args(self):
"""!
Setup command arguments.
Expand Down Expand Up @@ -913,11 +926,11 @@ def __init__(self, name, java_class, **kwargs):
def required_config(self):
"""!
Return list of required config.
Required config are: **hps_java_bin_jar**
Required config are: **hps_java_bin_jar**, **hps_fieldmaps_dir**
@return list of required config
"""
return ['hps_java_bin_jar']
return ['hps_java_bin_jar', 'hps_fieldmaps_dir']

def cmd_args(self):
"""!
Expand All @@ -936,6 +949,24 @@ def cmd_args(self):
args.append(self.java_class)
return args

def config(self, parser):
super().config(parser)
if self.hps_fieldmaps_dir is None:
self.hps_fieldmaps_dir = "{}/share/fieldmap".format(self.hpsmc_dir)
if not os.path.isdir(self.hps_fieldmaps_dir):
raise Exception("The fieldmaps dir does not exist: {}".format(self.hps_fieldmaps_dir))
logger.debug("Using fieldmap dir from install: {}".format(self.hps_fieldmaps_dir))
else:
logger.debug("Using fieldmap dir from config: {}".format(self.hps_fieldmaps_dir))

def setup(self):
logger.debug('Creating sym link to fieldmap dir: {}'.format(self.hps_fieldmaps_dir))
if not os.path.islink(os.getcwd() + os.path.sep + "fieldmap"):
os.symlink(self.hps_fieldmaps_dir, "fieldmap")
else:
logger.warning('Link to fieldmap dir already exists!')


class EvioToLcio(JavaTool):
"""!
Convert EVIO events to LCIO using the hps-java EvioToLcio command line tool.
Expand Down Expand Up @@ -985,6 +1016,7 @@ def optional_parameters(self):

def setup(self):
"""! Setup EvioToLcio component."""
super().setup()
if self.steering not in self.steering_files:
raise Exception("Steering '%s' not found in: %s" % (self.steering, self.steering_files))
self.steering_file = self.steering_files[self.steering]
Expand Down

0 comments on commit 62f629f

Please sign in to comment.