fix: job_id is an int

This commit is contained in:
Dominik Moritz Roth 2023-07-07 15:27:16 +02:00
parent 5e8d6d2552
commit 73b974458b

View File

@ -124,13 +124,15 @@ class Slate():
def _reps_for_job(self, schedulerC, job_id): def _reps_for_job(self, schedulerC, job_id):
reps = schedulerC.get('repetitions', 1) reps = schedulerC.get('repetitions', 1)
if job_id == None:
return range(0, reps)
num_jobs = self._calc_num_jobs(schedulerC) num_jobs = self._calc_num_jobs(schedulerC)
reps_for_job = [[]] * num_jobs reps_for_job = [[]] * num_jobs
for i in range(reps): for i in range(reps):
reps_for_job[i % num_jobs].append(i) reps_for_job[i % num_jobs].append(i)
return reps_for_job[job_id] return reps_for_job[job_id]
def run_local(self, filename, name, job_id=0): def run_local(self, filename, name, job_id):
config = self.load_config(filename, name) config = self.load_config(filename, name)
schedulerC = copy.deepcopy(config.get('scheduler', {})) schedulerC = copy.deepcopy(config.get('scheduler', {}))
rep_ids = self._reps_for_job(schedulerC, job_id) rep_ids = self._reps_for_job(schedulerC, job_id)
@ -245,7 +247,7 @@ class Slate():
parser.add_argument("experiment", nargs='?', default='DEFAULT') parser.add_argument("experiment", nargs='?', default='DEFAULT')
parser.add_argument("-s", "--slurm", action="store_true") parser.add_argument("-s", "--slurm", action="store_true")
parser.add_argument("-w", "--worker", action="store_true") parser.add_argument("-w", "--worker", action="store_true")
parser.add_argument("-j", "--job_id", default=0) parser.add_argument("-j", "--job_id", default=None, type=int)
args = parser.parse_args() args = parser.parse_args()