Skip to content

Commit 7925f19

Browse files
committed
Require resource declarations to specify model name before components
1 parent 4e7dde8 commit 7925f19

2 files changed

Lines changed: 38 additions & 34 deletions

File tree

‎ymmsl/v0_2/configuration.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,23 +584,21 @@ def _check_resources(
584584

585585
em_nompi = impl.execution_model is ExecutionModel.DIRECT
586586

587-
# can become just path again when we prefix resources with the model name
588-
if path[1:] not in self.resources:
587+
if path not in self.resources:
589588
if em_mpi:
590589
errors.append(f'Component "{path}" is missing a resource request')
591590
else:
592-
# also here
593591
res_mpi = isinstance(
594-
self.resources[path[1:]], (MPICoresResReq, MPINodesResReq))
592+
self.resources[path], (MPICoresResReq, MPINodesResReq))
595593

596594
if em_mpi and not res_mpi:
597595
errors.append(
598-
f'Component "{path[1:]}" has implementation "{impl_ref}",'
596+
f'Component "{path}" has implementation "{impl_ref}",'
599597
' which has an MPI execution model, but the resources'
600598
' requested for it do not ask for MPI processes.')
601599
elif res_mpi and em_nompi:
602600
errors.append(
603-
f'Component "{path[1:]}" has implementation "{impl_ref}",'
601+
f'Component "{path}" has implementation "{impl_ref}",'
604602
' which has a non-MPI execution model, but the resources'
605603
' requested for it ask for MPI processes.')
606604

‎ymmsl/v0_2/tests/conftest.py‎

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ def config_consistent_impl_ports() -> Configuration:
371371
]
372372

373373
resources = [
374-
ThreadedResReq(Reference('impl_no_ports'), 1),
375-
MPICoresResReq(Reference('impl_with_ports'), 4, 4),
374+
ThreadedResReq(Reference('implementations_test.impl_no_ports'), 1),
375+
MPICoresResReq(Reference('implementations_test2.impl_with_ports'), 4, 4),
376376
]
377377

378378
return Configuration(
@@ -427,10 +427,16 @@ def config_inconsistent_impl_ports() -> Configuration:
427427
]
428428

429429
resources = [
430-
ThreadedResReq(Reference('missing_implementation'), 1),
431-
ThreadedResReq(Reference('impl_ports_mismatch'), 1),
432-
MPICoresResReq(Reference('model_as_impl.impl_also_wrong'), 4, 4),
433-
ThreadedResReq(Reference('model_as_impl.impl_extra_ports'), 1),
430+
ThreadedResReq(
431+
Reference('implementations_test_broken.missing_implementation'), 1),
432+
ThreadedResReq(
433+
Reference('implementations_test_broken.impl_ports_mismatch'), 1),
434+
MPICoresResReq(
435+
Reference('implementations_test_broken.model_as_impl.impl_also_wrong'),
436+
4, 4),
437+
ThreadedResReq(
438+
Reference('implementations_test_broken.model_as_impl.impl_extra_ports'),
439+
1),
434440
]
435441

436442
return Configuration(
@@ -457,9 +463,9 @@ def config_consistent_custom_impls() -> Configuration:
457463
Program('initer2', executable=Path('initer2'))]
458464

459465
resources = [
460-
ThreadedResReq(Reference('c1'), 1),
461-
ThreadedResReq(Reference('c2.init_model'), 1),
462-
ThreadedResReq(Reference('c2.optional2'), 1),
466+
ThreadedResReq(Reference('test_model.c1'), 1),
467+
ThreadedResReq(Reference('test_model.c2.init_model'), 1),
468+
ThreadedResReq(Reference('test_model.c2.optional2'), 1),
463469
]
464470

465471
return Configuration(
@@ -482,8 +488,8 @@ def config_inconsistent_custom_impls() -> Configuration:
482488
[Component('init_model', Ports(), 'description', 'initer1')])
483489

484490
resources = [
485-
ThreadedResReq(Reference('c1'), 1),
486-
ThreadedResReq(Reference('c2.init_model'), 1),
491+
ThreadedResReq(Reference('test_model.c1'), 1),
492+
ThreadedResReq(Reference('test_model.c2.init_model'), 1),
487493
]
488494

489495
return Configuration(
@@ -539,9 +545,9 @@ def config_consistent_settings() -> Configuration:
539545
programs = [program_a, program_b, program_c]
540546

541547
resources = [
542-
ThreadedResReq(Reference('c1'), 1),
543-
MPICoresResReq(Reference('submodel.c1'), 16),
544-
MPICoresResReq(Reference('submodel.c2'), 4, 4)]
548+
ThreadedResReq(Reference('supported_settings_test.c1'), 1),
549+
MPICoresResReq(Reference('supported_settings_test.submodel.c1'), 16),
550+
MPICoresResReq(Reference('supported_settings_test.submodel.c2'), 4, 4)]
545551

546552
return Configuration(
547553
'config3', None, [model1, model2], None, settings, programs, resources)
@@ -580,12 +586,12 @@ def config_consistent_resources() -> Configuration:
580586
programs = [Program(x, script='script', execution_model=em[x]) for x in 'abcd']
581587

582588
resources = [
583-
ThreadedResReq(Reference('singlethreaded'), 1),
584-
ThreadedResReq(Reference('multithreaded'), 8),
585-
MPICoresResReq(Reference('submodel.mpi_cores1'), 16),
586-
MPICoresResReq(Reference('submodel.mpi_cores2'), 4, 4),
587-
MPINodesResReq(Reference('submodel.mpi_nodes1'), 10, 16),
588-
MPINodesResReq(Reference('submodel.mpi_nodes2'), 10, 4, 4)]
589+
ThreadedResReq(Reference('resources_test.singlethreaded'), 1),
590+
ThreadedResReq(Reference('resources_test.multithreaded'), 8),
591+
MPICoresResReq(Reference('resources_test.submodel.mpi_cores1'), 16),
592+
MPICoresResReq(Reference('resources_test.submodel.mpi_cores2'), 4, 4),
593+
MPINodesResReq(Reference('resources_test.submodel.mpi_nodes1'), 10, 16),
594+
MPINodesResReq(Reference('resources_test.submodel.mpi_nodes2'), 10, 4, 4)]
589595

590596
return Configuration(
591597
'consistent_resources', None, [model1, model2], None, None, programs,
@@ -611,9 +617,9 @@ def config_inconsistent_resources() -> Configuration:
611617
Program('b', script='b', execution_model=ExecutionModel.INTELMPI)]
612618

613619
resources = [
614-
ThreadedResReq(Ref('singlethreaded'), 1),
615-
ThreadedResReq(Ref('with_mpi'), 2),
616-
MPICoresResReq(Ref('without_mpi'), 10)]
620+
ThreadedResReq(Ref('got_resources.singlethreaded'), 1),
621+
ThreadedResReq(Ref('got_resources.with_mpi'), 2),
622+
MPICoresResReq(Ref('got_resources.without_mpi'), 10)]
617623

618624
return Configuration(
619625
'test_config', None, [model1, model2], None, None, programs, resources)
@@ -651,11 +657,11 @@ def config_consistent_partial_resources() -> Configuration:
651657
programs = [Program(x, script='script', execution_model=em[x]) for x in 'abcd']
652658

653659
resources = [
654-
ThreadedResReq(Reference('singlethreaded'), 1),
655-
ThreadedResReq(Reference('multithreaded'), 4),
656-
MPICoresResReq(Reference('mpi_cores1'), 16),
657-
MPINodesResReq(Reference('mpi_nodes1'), 10, 16),
658-
MPINodesResReq(Reference('mpi_nodes2'), 10, 4, 4)]
660+
ThreadedResReq(Reference('resources_test.singlethreaded'), 1),
661+
ThreadedResReq(Reference('resources_test.multithreaded'), 4),
662+
MPICoresResReq(Reference('resources_test2.mpi_cores1'), 16),
663+
MPINodesResReq(Reference('resources_test2.mpi_nodes1'), 10, 16),
664+
MPINodesResReq(Reference('resources_test2.mpi_nodes2'), 10, 4, 4)]
659665

660666
return Configuration(
661667
'consistent_resources', None, [model1, model2], None, None, programs,

0 commit comments

Comments
 (0)