diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index cc2a929c617a4c8e1366cc4e7d2903e0de01ba79..5bd145e4cb350314d9aadb157152189fac764f3c 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -237,13 +237,17 @@ class Population( def jobID(self): """ - Function to return the job ID number of this process + Function to return the job ID number of this process as a string. Normal processes return their process ID (PID) HPC processes return whatever HPC_jobID() gives. """ if self.HPC_job(): jobID = self.HPC_jobID() + if not jobID: + # fallback: use process ID but with "HPC" prepended + # (this should never happen!) + jobID = "HPC{}".format(self.process_ID) else: jobID = "{}".format(self.process_ID) return jobID @@ -374,7 +378,7 @@ class Population( # get the cmd-line args in the form x=y cmdline_args = sys.argv[1:] - + if cmdline_args: self.verbose_print( "Found cmdline args. Parsing them now", @@ -385,7 +389,7 @@ class Population( # Grab the input and split them up, while accepting only non-empty entries # cmdline_args = args self.grid_options["_commandline_input"] = cmdline_args - + # Make dict and fill it cmdline_dict = {} for cmdline_arg in cmdline_args: @@ -1614,17 +1618,18 @@ class Population( # that was on, we log each current system to a file (each thread has one). # Each new system overrides the previous if self.grid_options["log_args"]: + argfile = os.path.join( + self.grid_options["log_args_dir"], + "current_system", + "process_{}.txt".format(self.jobID()), + ) with self.open( - os.path.join( - self.grid_options["log_args_dir"], - "current_system", - "process_{}.txt".format(self.process_ID), - ), - "w", - encoding="utf-8", + argfile, + "w", + encoding="utf-8", ) as f: - binary_cmdline_string = self._return_argline(full_system_dict) - f.write(binary_cmdline_string) + binary_c_cmdline_string = self._return_argline(full_system_dict) + f.write(binary_c_cmdline_string) f.close() ############## diff --git a/binarycpython/utils/population_extensions/HPC.py b/binarycpython/utils/population_extensions/HPC.py index dadfab449237e97ed06b2d77c3014665ba5c0244..5a5555a75a3c3ab0522b3c594385b803871fa500 100644 --- a/binarycpython/utils/population_extensions/HPC.py +++ b/binarycpython/utils/population_extensions/HPC.py @@ -304,7 +304,7 @@ class HPC(condor, slurm): def HPC_jobID(self): """ - Function to return an HPC (Slurm or Condor) job id in the form x.y. Returns None if not an HPC job. + Function to return an HPC (Slurm or Condor) job id in the form of a string, x.y. Returns None if not an HPC job. """ if self.grid_options["slurm"] > 0: diff --git a/binarycpython/utils/population_extensions/condor.py b/binarycpython/utils/population_extensions/condor.py index 31531021996c9649576c94cd9bdaef9363f79538..04a6f8b75938fdca36b064af6b22081cd072e86d 100644 --- a/binarycpython/utils/population_extensions/condor.py +++ b/binarycpython/utils/population_extensions/condor.py @@ -37,7 +37,7 @@ class condor: def condorID(self, ClusterID=None, Process=None): """ - Function to return a Condor job ID. The ClusterID and Process passed in are used if given, otherwise we default to the condor_ClusterID and condor_Process in grid_options. + Function to return a Condor job ID as a string, [ClusterID].[Process]. The ClusterID and Process passed in are used if given, otherwise we default to the condor_ClusterID and condor_Process in grid_options. """ if ClusterID is None: ClusterID = self.grid_options["condor_ClusterID"] diff --git a/binarycpython/utils/population_extensions/slurm.py b/binarycpython/utils/population_extensions/slurm.py index c362c0a0bcded74dba17ce7936bc48206207171c..1baf701d0337f5b864b29a8078fe4331c23b06e3 100644 --- a/binarycpython/utils/population_extensions/slurm.py +++ b/binarycpython/utils/population_extensions/slurm.py @@ -35,7 +35,7 @@ class slurm: def slurmID(self, jobid=None, jobarrayindex=None): """ - Function to return a Slurm job ID. The jobid and jobarrayindex passed in are used if given, otherwise we default to the jobid and jobarrayindex in grid_options. + Function to return a Slurm job ID as a string, [jobid].[jobarrayindex]. The jobid and jobarrayindex passed in are used if given, otherwise we default to the jobid and jobarrayindex in grid_options. """ if jobid is None: jobid = self.grid_options["slurm_jobid"]