refactor: use dict instead of set for consistent order

This commit is contained in:
张泊明518370910136 2025-03-04 15:16:18 -05:00
parent e0da740871
commit 56ecd35e46
GPG Key ID: D47306D7062CDA9D
3 changed files with 23 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import os import os
from typing import Set from typing import Dict
from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.models import joj1, repo, result, task
from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT
@ -27,7 +27,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
# Construct health check stage # Construct health check stage
if not repo_conf.force_skip_health_check_on_test or not current_test: if not repo_conf.force_skip_health_check_on_test or not current_test:
result_conf.stage.stages.append(get_health_check_stage(repo_conf)) result_conf.stage.stages.append(get_health_check_stage(repo_conf))
cached: Set[str] = set() cached: Dict[str, None] = {}
# Convert each stage in the task configuration # Convert each stage in the task configuration
for task_stage in task_conf.stages: for task_stage in task_conf.stages:
result_conf.stage.stages.append(get_conf_stage(task_conf, task_stage, cached)) result_conf.stage.stages.append(get_conf_stage(task_conf, task_stage, cached))

View File

@ -1,6 +1,6 @@
import re import re
import shlex import shlex
from typing import Any, Callable, Dict, List, Set, Tuple from typing import Any, Callable, Dict, List, Tuple
from joj3_config_generator.models import result, task from joj3_config_generator.models import result, task
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
@ -9,7 +9,7 @@ from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
def get_conf_stage( def get_conf_stage(
task_conf: task.Config, task_conf: task.Config,
task_stage: task.Stage, task_stage: task.Stage,
cached: Set[str], cached: Dict[str, None],
) -> result.StageDetail: ) -> result.StageDetail:
conf_stage = result.StageDetail( conf_stage = result.StageDetail(
name=task_stage.name, name=task_stage.name,
@ -55,7 +55,9 @@ def get_processed_dict(
return processed_dict return processed_dict
def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.ExecutorWith: def get_executor_with(
task_stage: task.Stage, cached: Dict[str, None]
) -> result.ExecutorWith:
file_import = task_stage.files.import_ file_import = task_stage.files.import_
copy_in_files = [file for file in file_import if file not in cached] copy_in_files = [file for file in file_import if file not in cached]
file_export = task_stage.files.export file_export = task_stage.files.export
@ -81,7 +83,7 @@ def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.Execut
cases=[], cases=[],
) )
for file in file_export: for file in file_export:
cached.add(file) cached[file] = None
return executor_with_config return executor_with_config

View File

@ -222,11 +222,11 @@
} }
}, },
"copyInCached": { "copyInCached": {
"h7/build/ex2-msan": "h7/build/ex2-msan", "h7/build/ex2": "h7/build/ex2",
"h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-asan": "h7/build/ex2-asan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
"h7/build/ex2": "h7/build/ex2" "h7/build/ex2-msan": "h7/build/ex2-msan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
"copyOut": [ "copyOut": [
@ -322,11 +322,11 @@
} }
}, },
"copyInCached": { "copyInCached": {
"h7/build/ex2-msan": "h7/build/ex2-msan", "h7/build/ex2": "h7/build/ex2",
"h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-asan": "h7/build/ex2-asan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
"h7/build/ex2": "h7/build/ex2" "h7/build/ex2-msan": "h7/build/ex2-msan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
"copyOut": [ "copyOut": [
@ -444,11 +444,11 @@
"cpuSetLimit": "", "cpuSetLimit": "",
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h7/build/ex2-msan": "h7/build/ex2-msan", "h7/build/ex2": "h7/build/ex2",
"h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-asan": "h7/build/ex2-asan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
"h7/build/ex2": "h7/build/ex2" "h7/build/ex2-msan": "h7/build/ex2-msan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
"copyOut": [ "copyOut": [
@ -587,11 +587,11 @@
"cpuSetLimit": "", "cpuSetLimit": "",
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h7/build/ex2-msan": "h7/build/ex2-msan", "h7/build/ex2": "h7/build/ex2",
"h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-asan": "h7/build/ex2-asan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
"h7/build/ex2": "h7/build/ex2" "h7/build/ex2-msan": "h7/build/ex2-msan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
"copyOut": [ "copyOut": [
@ -684,11 +684,11 @@
"cpuSetLimit": "", "cpuSetLimit": "",
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h7/build/ex2-msan": "h7/build/ex2-msan", "h7/build/ex2": "h7/build/ex2",
"h7/build/ex2-asan": "h7/build/ex2-asan", "h7/build/ex2-asan": "h7/build/ex2-asan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan", "h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
"h7/build/ex2": "h7/build/ex2" "h7/build/ex2-msan": "h7/build/ex2-msan",
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
"copyOut": [ "copyOut": [