Skip to content

Commit d17d7ae

Browse files
committed
Handle save paths that do not exist
This gives the genotype storage a way to create paths that do not exist before trying to save the genotype.json there.
1 parent ef276e3 commit d17d7ae

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

common/darts/storage/genotype.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def save_genotype(self, genotype: Genotype, filename='genotype.json') -> None:
2323
filename: name of the save file
2424
"""
2525
genotype = self._replace_range(genotype)
26+
os.makedirs(self.root, exist_ok=True)
2627
path = os.path.join(self.root, filename)
2728
with open(path, 'w') as outfile:
2829
json.dump(genotype, outfile)

examples/darts/uno/results/.gitkeep

Whitespace-only changes.

examples/darts/uno/uno_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run(params):
7070
train_meter = darts.EpochMeter(tasks, 'train')
7171
valid_meter = darts.EpochMeter(tasks, 'valid')
7272

73-
genotype_store = darts.GenotypeStorage(root=args.savepath)
73+
genotype_store = darts.GenotypeStorage(root=args.save_path)
7474

7575
for epoch in range(args.epochs):
7676

@@ -161,7 +161,7 @@ def train(trainloader,
161161
logger.info(f'Step: {step} loss: {meter.loss_meter.avg:.4}')
162162

163163
meter.update_epoch()
164-
meter.save(args.savepath)
164+
meter.save(args.save_path)
165165

166166

167167

@@ -186,7 +186,7 @@ def validate(validloader, model, criterion, args, tasks, meter, device):
186186
logger.info(f'>> Validation: {step} loss: {meter.loss_meter.avg:.4}')
187187

188188
meter.update_epoch()
189-
meter.save(args.savepath)
189+
meter.save(args.save_path)
190190

191191

192192
def main():

0 commit comments

Comments
 (0)