File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -350,6 +350,8 @@ def init(
350350 gitignore += f"{ res_path .relative_to (target )} /\n "
351351 target .joinpath (".gitignore" ).write_text (gitignore )
352352
353+ if not parsed_config .problem .location .is_absolute ():
354+ parsed_config .problem .location = target / parsed_config .problem .location
353355 problem_obj = parsed_config .loaded_problem
354356 if schemas :
355357 instance : type [Instance ] = problem_obj .instance_cls
Original file line number Diff line number Diff line change @@ -624,15 +624,6 @@ class AlgobattleConfig(BaseModel):
624624
625625 model_config = ConfigDict (revalidate_instances = "always" )
626626
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-
636627 @cached_property
637628 def loaded_problem (self ) -> Problem :
638629 """The problem this config uses."""
Original file line number Diff line number Diff line change @@ -332,12 +332,15 @@ def score(
332332 def load_file (cls , name : str , file : Path ) -> Self :
333333 """Loads the problem from the specified file."""
334334 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
341344
342345 @classmethod
343346 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"
44
55[project ]
66name = " algobattle-base"
7- version = " 4.0.0 "
7+ version = " 4.0.1 "
88description = " The Algobattle lab course package."
99readme = " README.md"
1010requires-python = " >=3.11"
You can’t perform that action at this time.
0 commit comments