File tree Expand file tree Collapse file tree 4 files changed +12
-16
lines changed Expand file tree Collapse file tree 4 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,8 @@ def init(
350
350
gitignore += f"{ res_path .relative_to (target )} /\n "
351
351
target .joinpath (".gitignore" ).write_text (gitignore )
352
352
353
+ if not parsed_config .problem .location .is_absolute ():
354
+ parsed_config .problem .location = target / parsed_config .problem .location
353
355
problem_obj = parsed_config .loaded_problem
354
356
if schemas :
355
357
instance : type [Instance ] = problem_obj .instance_cls
Original file line number Diff line number Diff line change @@ -624,15 +624,6 @@ class AlgobattleConfig(BaseModel):
624
624
625
625
model_config = ConfigDict (revalidate_instances = "always" )
626
626
627
- @model_validator (mode = "after" )
628
- def check_problem_defined (self ) -> Self :
629
- """Validates that the specified problem is either installed or dynamically specified."""
630
- prob = self .match .problem
631
- if not self .problem .location .is_file () and prob not in Problem .available ():
632
- raise ValueError (f"The specified problem { prob } cannot be found" )
633
- else :
634
- return self
635
-
636
627
@cached_property
637
628
def loaded_problem (self ) -> Problem :
638
629
"""The problem this config uses."""
Original file line number Diff line number Diff line change @@ -332,12 +332,15 @@ def score(
332
332
def load_file (cls , name : str , file : Path ) -> Self :
333
333
"""Loads the problem from the specified file."""
334
334
existing_problems = cls ._problems .copy ()
335
- import_file_as_module (file , "__algobattle_problem__" )
336
- new_problems = {n : p for n , p in cls ._problems .items () if n not in existing_problems }
337
- if name not in new_problems :
338
- raise ValueError (f"The { name } problem is not defined in { file } " )
339
- else :
340
- return cls ._problems [name ]
335
+ cls ._problems = {}
336
+ try :
337
+ import_file_as_module (file , "__algobattle_problem__" )
338
+ if name not in cls ._problems :
339
+ raise ValueError (f"The { name } problem is not defined in { file } " )
340
+ else :
341
+ return cls ._problems [name ]
342
+ finally :
343
+ cls ._problems = existing_problems
341
344
342
345
@classmethod
343
346
def load (cls , name : str , file : Path | None = None ) -> Self :
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "pdm.backend"
4
4
5
5
[project ]
6
6
name = " algobattle-base"
7
- version = " 4.0.0 "
7
+ version = " 4.0.1 "
8
8
description = " The Algobattle lab course package."
9
9
readme = " README.md"
10
10
requires-python = " >=3.11"
You can’t perform that action at this time.
0 commit comments