diff --git a/pyproject.toml b/pyproject.toml index 12cc91c9..1d034bb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sampo" -version = "0.1.1.249" +version = "0.1.1.251" description = "Open-source framework for adaptive manufacturing processes scheduling" authors = ["iAirLab "] license = "BSD-3-Clause" diff --git a/sampo/pipeline/base.py b/sampo/pipeline/base.py index fd7631c1..4c5f7788 100644 --- a/sampo/pipeline/base.py +++ b/sampo/pipeline/base.py @@ -23,7 +23,7 @@ class InputPipeline(ABC): @abstractmethod def wg(self, wg: WorkGraph | pd.DataFrame | str, - full_connection: bool = False, + is_wg_has_full_info_about_connections: bool = False, change_base_on_history: bool = False) -> 'InputPipeline': ... diff --git a/sampo/schemas/works.py b/sampo/schemas/works.py index 6aaa9d43..1d4af977 100644 --- a/sampo/schemas/works.py +++ b/sampo/schemas/works.py @@ -20,6 +20,7 @@ def __init__(self, material_reqs: list[MaterialReq] = None, object_reqs: list[ConstructionObjectReq] = None, zone_reqs: list[ZoneReq] = None, + description: str = '', group: str = 'default', is_service_unit: bool = False, volume: float = 0, @@ -32,6 +33,7 @@ def __init__(self, :param material_reqs: list of required materials (e.g. logs, stones, gravel etc.) :param object_reqs: list of required objects (e.g. electricity, pipelines, roads) :param zone_reqs: list of required zone statuses (e.g. opened/closed doors, attached equipment, etc.) + :param description: the description. It is useful, for example, to show it on visualization :param group: union block of works :param is_service_unit: service units are additional vertexes :param volume: scope of work @@ -54,6 +56,7 @@ def __init__(self, self.object_reqs = object_reqs self.material_reqs = material_reqs self.zone_reqs = zone_reqs + self.description = description self.group = group self.is_service_unit = is_service_unit self.volume = volume @@ -62,7 +65,7 @@ def __init__(self, self.workground_size = workground_size def __del__(self): - for name, attr in self.__dict__.items(): + for attr in self.__dict__.values(): del attr def need_materials(self) -> list[Material]: diff --git a/sampo/userinput/parser/csv_parser.py b/sampo/userinput/parser/csv_parser.py index c9222bf4..2f7f1f07 100644 --- a/sampo/userinput/parser/csv_parser.py +++ b/sampo/userinput/parser/csv_parser.py @@ -36,8 +36,13 @@ def read_graph_info(project_info: str, predecessor_ids: list[str] - Ids of predecessors of the current task, connection_types: list[str] - Types of links between the current task and its predecessors, lags: float - Time lags, - min_req: dict[str: float] - A dictionary containing the minimum amount of each resource that is required to perform the current task - max_req: dict[str: float] - A dictionary containing the maximum amount of each resource that is required to perform the current task + min_req: dict[str: float] - A dictionary containing the minimum amount of each resource + that is required to perform the current task + max_req: dict[str: float] - A dictionary containing the maximum amount of each resource + that is required to perform the current task + description: str - A task description + required_status: dict[str: float] - A dictionary containing the zone statuses required + to perform the current task Schema of history .csv file (optional data): mandatory fields: diff --git a/sampo/userinput/parser/general_build.py b/sampo/userinput/parser/general_build.py index 732b5886..9f191f83 100644 --- a/sampo/userinput/parser/general_build.py +++ b/sampo/userinput/parser/general_build.py @@ -9,7 +9,7 @@ from sampo.generator.pipeline.project import get_start_stage, get_finish_stage from sampo.schemas.contractor import Contractor from sampo.schemas.graph import GraphNode, WorkGraph, EdgeType -from sampo.schemas.requirements import WorkerReq +from sampo.schemas.requirements import WorkerReq, ZoneReq from sampo.schemas.resources import Worker from sampo.schemas.works import WorkUnit @@ -21,7 +21,7 @@ class Graph: def __init__(self): self.graph = defaultdict(list) - def add_edge(self, u, v, weight = None): + def add_edge(self, u, v, weight=None): self.graph[u].append((v, weight)) def dfs_cycle(self, u, visited): @@ -233,9 +233,15 @@ def build_work_graph(frame: pd.DataFrame, resource_names: list[str]) -> WorkGrap for res_name in resource_names if row[res_name] > 0] is_service_unit = len(reqs) == 0 + + zone_reqs = [ZoneReq(*v) for v in eval(row['required_statuses']).items()] \ + if 'required_statuses' in frame.columns else [] + + description = row['description'] if 'description' in frame.columns else '' + work_unit = WorkUnit(row['activity_id'], row['granular_name'], reqs, group=row['activity_name'], - volume=row['volume'], volume_type=row['measurement'], is_service_unit=is_service_unit, - display_name=row['activity_name']) + description=description, volume=row['volume'], volume_type=row['measurement'], + is_service_unit=is_service_unit, display_name=row['activity_name'], zone_reqs=zone_reqs) has_succ |= set(row['edges'][0]) parents = [(id_to_node[p_id], lag, conn_type) for p_id, conn_type, lag in row.edges] node = GraphNode(work_unit, parents) diff --git a/tests/parser/csv_parser_test.py b/tests/parser/csv_parser_test.py index e38832df..a02217f9 100644 --- a/tests/parser/csv_parser_test.py +++ b/tests/parser/csv_parser_test.py @@ -16,4 +16,4 @@ def test_work_graph_csv_parser(): except Exception as e: raise WorkGraphBuildingException(f'There is no way to build work graph, {e}') - + os.remove(os.path.join(sys.path[0], 'tests/parser/repaired.csv'))