1515import os
1616import shutil
1717import tempfile
18- from typing import cast
1918
20- from pisek .user_errors import InvalidArgument , InvalidOperation , TestingFailed
19+ from pisek .user_errors import (
20+ InvalidArgument ,
21+ InvalidOperation ,
22+ TestingFailed ,
23+ NotSupported ,
24+ )
2125from pisek .utils .paths import (
2226 BUILD_DIR ,
2327 TESTS_DIR ,
2832 OpendataOutputPath ,
2933)
3034from pisek .utils .pipeline_tools import run_pipeline
35+ from pisek .config .config_types import GenType
3136from pisek .config .config_hierarchy import DEFAULT_CONFIG_FILENAME
3237from pisek .config .task_config import load_config
3338from pisek .config .config_tools import export_config
@@ -54,25 +59,33 @@ def __init__(
5459 config_filename : str = DEFAULT_CONFIG_FILENAME ,
5560 ) -> None :
5661 self ._path = path
57- self ._env_args = ENV_ARGS | {
58- "pisek_dir" : pisek_dir ,
59- "config_filename" : config_filename ,
60- }
62+ self ._pisek_dir = pisek_dir or os .environ .get ("PISEK_DIRECTORY" )
63+ self ._config_filename = config_filename
6164
6265 def test (self , strict : bool = True , disable_cache : bool = False ) -> bool :
6366 try :
6467 run_pipeline (
6568 self ._path ,
6669 TaskPipeline ,
70+ pisek_dir = self ._pisek_dir ,
71+ config_filename = self ._config_filename ,
6772 disable_cache = disable_cache ,
6873 strict = strict ,
69- ** self . _env_args ,
74+ ** ENV_ARGS ,
7075 )
7176 except TestingFailed :
7277 return False
7378 return True
7479
7580 def build (self , path : str ) -> "BuiltTask" :
81+ config = load_config (
82+ self ._path , self ._pisek_dir , self ._config_filename , False , True
83+ )
84+ if config .tests .gen_type == GenType .cms_old :
85+ raise NotSupported (
86+ "For opendata tasks, the cms-old generator is not supported."
87+ )
88+
7689 if os .path .exists (path ):
7790 if not os .path .isdir (path ):
7891 raise InvalidArgument (f"{ path } should be a directory" )
@@ -83,9 +96,11 @@ def build(self, path: str) -> "BuiltTask":
8396 run_pipeline (
8497 self ._path ,
8598 TaskPipeline ,
99+ pisek_dir = self ._pisek_dir ,
100+ config_filename = self ._config_filename ,
86101 target = TestingTarget .build ,
87102 disable_cache = True ,
88- ** self . _env_args ,
103+ ** ENV_ARGS ,
89104 )
90105
91106 COPIED_PATHS = [
@@ -106,9 +121,8 @@ def build(self, path: str) -> "BuiltTask":
106121
107122 export_config (
108123 self ._path ,
109- cast (str | None , self ._env_args ["pisek_dir" ])
110- or os .environ .get ("PISEK_DIRECTORY" ),
111- cast (str , self ._env_args ["config_filename" ]),
124+ self ._pisek_dir ,
125+ self ._config_filename ,
112126 os .path .join (path , DEFAULT_CONFIG_FILENAME ),
113127 )
114128
0 commit comments