modules.writers
Classes
- class modules.writers.GdimSimpleTablesWriter
Write a TableCollection (multiple tables) to a simgle json formate for gdim rendering.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = None, auto_run: bool = True, tables: PortTypeHint.TableCollection | PortTypeHint.TableData | None = None, highlight_rows: PortTypeHint.TablesRowMask | None = None, name_type: Literal[name, title] = 'name', columns: list[str] | None = None, precision: dict[str, int | None] | None = None, table_name_type: Literal[name, title] = 'title', column_name_type: Literal[name, title] = 'title', highlight_rows_required: bool = False) None
Initialize the GdimSimpleTablesWriter object.
Parameters
- tablesTableCollection | TableData | None, default: None
The table collection to be converted. If it’s TableCollection, serveral table will be converted and keys are either table name or table title. If it’s TableData, only one table will be converted.
- highlight_rowsPortTypeHint.TablesRowMask | None, default: None
A mask to mark the rows to be highlighted. Key is the name of the table. Value is mask which is a list of boolean values. name_type: Literal[“name”, “title”], default: “name” The type of the names used in column names selected, the key of precision and the name of the main table.
- columnslist[str] | None, default: None
The columns to be converted. All tables in the TableCollection will use the same columns. If a column is not found in a table, it will be ignored. If None, all columns will be converted. If name_type is “name”, the columns should be the names of the columns. If name_type is “title”, the columns should be the titles of the columns. The table will be rendered in the same sequence of the columns. precision: dict[str, int] | None, default: None The precision of the table. Key is the name of the column. If name_type is “name”, the key is the name of the column. If name_type is “title”, the key is the title of the column. table_name_type: Literal[“name”, “title”], default: “title” The type of the names used for the table names in the output. column_name_type: Literal[“name”, “title”], default: “title” The type of the names used for the column names in the output.
- highlight_rows_requiredbool, default: False
Whether the highlight rows are required. If it’s True, the InputHighlightRows cannot be None, or None will be returned after execution.
Properties:
- InputTables
- InputHighlightRows
- OutputRenderTables
- class modules.writers.GdimRenderTableWriter
Convert a TableData, TableCollection or SingleResult to a json format so that it can be rendered on Gdim.
Only one table can be generated.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = None, auto_run: bool = True, data: PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.SingleResult | None = None, name_type: Literal[name, title] = 'name', columns: list[str] | None = None, precision: dict[str, int | None] | None = None, group_by: str | None = None, main_table: str | None = None, sub_tables: list[str] | None = None) None
Initialize the GdimRenderTableWriter object.
Parameters
- dataTableData | TableCollection | SingleResult | None, default: None
The data to be converted. If it’s TableCollection, the tables will be merged into a single table by columns. name_type: Literal[“name”, “title”], default: “name” The type of the names used in column names selected, the key of precision and the name of the main table.
- columnslist[str] | None, default: None
The columns to be converted. If None, all columns will be converted. If name_type is “name”, the columns should be the names of the columns. If name_type is “title”, the columns should be the titles of the columns. precision: dict[str, int] | None, default: None The precision of the table. Key is the name of the column. If name_type is “name”, the key is the name of the column. If name_type is “title”, the key is the title of the column.
- group_bystr | None, default: None
The column name to be grouped by. It’s used when the table_data is a TableCollection. If None, the “group_by” will be the first column with the same name in all tables. If the name_type is “title”, the group_by should be the title of the column. If the name_type is “name”, the group_by should be the name of the column.
- main_tablestr | None, default: None
The name of the main table. It’s used when the table_data is a TableCollection. If None, the table with the least number of rows will be used as the main table. If the name_type is “title”, the main_table should be the title of the main table. If the name_type is “name”, the main_table should be the name of the main table.
- sub_tableslist[str] | None, default: None
The names of the sub tables. It’s used when the table_data is a TableCollection. If None, all tables except the main table will be used as sub tables.
Properties:
- InputData
- OutputRenderTable
- class modules.writers.DocDataWriter
Write all kinds of result to a data format that can be used to generate a .docx document.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'DocDataWriter', auto_run: bool = True, data: PortTypeHint.SingleResult | PortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.FilePath | PortTypeHint.FilesPath | None = None, precision: int | dict[str, int | None] | None = None, datetime_format: str | dict[str, str | None] | None = None, merge_strategy: Literal[auto, none, explicit] = 'auto', explicit_merges: list[dict[str, str | list[str]]] | None = None, table_doc_key_name: str | None = None, table_doc_key_title: str | None = None, joiner: str = ',', files_path_to_list: str | None = None, files_path: list[str] | list[Path] | list[dict] | None = None, latex_to_unicode_keys: str | list[str] | dict[str, str | list[str]] | None = None) None
Initialize the DocDataWriter object.
Parameters
- dataSingleResult | ResultModel | TableData | TableCollection | FilePath | FilesPath | None, default: None
The data to be written to a format that can be used for .docx document. For multiple data items, use TableCollection (for tables) or compose multiple DocDataWriter modules with MergeDocData. precision: int | dict[str, int | None] | None, default: None The precision of numeric values for formatting. Controls the number of decimal places for numeric data when exported to document format.
int: Apply the same precision to ALL numeric columns/values (convenient)
Examples
- latex_to_unicode_keys="model_expression" # Single root key - latex_to_unicode_keys=["model_expression", "formula"] # Multiple root keys - latex_to_unicode_keys={"table1": "column1"} # Single table column - latex_to_unicode_keys={"table1": ["col1", "col2"]} # Multiple columns in table - latex_to_unicode_keys={"__root__": ["key1"], "table1": ["col1"]} # MixedNotes
Keys can be either field names or field titles.
Attributes:
- InputData: PortReference[PortTypeHint.SingleResult | PortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.FilePath | PortTypeHint.FilesPath]
- OutputDocData: PortReference[PortTypeHint.DocData]
- class modules.writers.MergeDocData
Merge the data from multiple DocData objects into a single DocData object.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'MergeDocData', auto_run: bool = True, all_ports_required: bool = True) None
Initialize the MergeDocData object.
Parameters
- all_ports_requiredbool, default: True
If True, the execution will be blocked until all the dynamic ports are connected with valid data.
Attributes:
- OutputDocData: PortReference[PortTypeHint.DocData]
- class modules.writers.DocPrinter
Write the doc data to a .docx document.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = None, auto_run: bool = True, doc_data: PortTypeHint.DocData | None = None, template: str | Path | dict | list[str | Path | dict] | None = None, output_dir: str | Path | None = None, output_name: str | list[str] | None = None, image_size_type: Literal[width, height] | dict[str, Literal[width, height]] = 'width', image_size: float | int | dict[str, float | int] | dict[str, list[float | int]] | None = None, save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize the DocPrinter object.
Parameters
- doc_dataPortTypeHint.DocData | None
The doc data to be printed.
- templatestr | Path | list[str | Path] | dict | list[dict] | None
The template file or files used for printing. If None, the module will not be executed. If str or Path, the template file path should be specified. If list[str | Path], the template files should be specified. If dict, it will be converted to a GdimMinIOFile object to get the template from minIO server. If list[dict], it will be converted to a list of GdimMinIOFile objects to get the template from minIO server.
- output_dirstr | Path | None, default: None
The directory to save the generated document.
‘workspace’ of pipeline has priority over the ‘output_dir’.
If both ‘output_dir’ and ‘workspace’ are None, the current working directory will be used.
- output_namestr | list[str] | None
The name of the generated document. If list[str], the DocPrinter will try to print all the with all the doc templates with corresponding output names. If None, the name of the ‘template’ with a suffix ‘_printed’ will be used. image_size_type: Literal[“width”, “height”] | dict[str, Literal[“width”, “height”]], default: “width” The type of the image size. If “width”, the image size will be set to the width of the image. If “height”, the image size will be set to the height of the image. If dict, different key can use different type of image size. If the key is not found,
widthwill be used as default. image_size: float | int | dict[str, float | int] | dict[str, list[float | int]] | None, default: None The size of the image inmm. If float | int, all images will use this size. If dict[str, float | int],keyis the key in thedoc_dataand thevalueis the size of the image. If dict[str, list[float | int]],keyis the key in thedoc_dataand thevalueis the size for each image in the list. If None, the image size will be as same as its original size.- save_to_gdimbool, default: False
If True, the generated document will also be saved to the gdim file server.
- tokenstr | None
The token of the user. Must be provided when
save_to_gdimis True.- proj_idint | str | None
The id of the gdim project. Must be provided when
save_to_gdimis True.- hoststr | None
The host of the gdim platform. Ports
- InputDocDataPortReference[PortTypeHint.DocData]
The doc data to be printed.
- InputTokenPortReference[PortTypeHint.Token]
The token of the user.
- OutputFilePortReference[PortTypeHint.FilePath | PortTypeHint.FilesPath | PortTypeHint.GdimFile | PortTypeHint.GdimFiles]
The files of the generated document.
- execute() PortTypeHint.FilePath | PortTypeHint.FilesPath | PortTypeHint.GdimFile | PortTypeHint.GdimFiles | None
Attributes:
- InputDocData: PortReference[PortTypeHint.DocData]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.FilesPath | PortTypeHint.GdimFile | PortTypeHint.GdimFiles]
- class modules.writers.ExcelPrinter
Write the doc data to a .xlsx document.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'ExcelPrinter', auto_run: bool = True, doc_data: PortTypeHint.DocData | None = None, template: str | Path | dict | list[str | Path | dict] | None = None, output_dir: str | Path | None = None, output_name: str | list[str] | None = None, include_table_titles: bool = False, apply_table_borders: bool = False, border_style: str = 'thin', image_size_type: Literal[width, height] | dict[str, Literal[width, height]] = 'width', image_size: dict[str, float] | dict[str, list[float]] | None = None, process_sheets: str | list[str] | Literal[active, all] = 'all', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize the ExcelPrinter object.
Parameters
- doc_dataPortTypeHint.DocData | None
The doc data to be printed.
- templatestr | Path | dict | list[str | Path | dict] | None
The template file or files used for printing. If None, the module will not be executed. If str or Path, the template file path should be specified. If list[str | Path], the template files should be specified. If dict, it will be converted to a GdimMinIOFile object to get the template from minIO server. If list[dict], it will be converted to a list of GdimMinIOFile objects to get the template from minIO server.
- output_dirstr | None
The directory to save the generated document.
‘workspace’ of pipeline has priority over the ‘output_dir’.
If both ‘output_dir’ and ‘workspace’ are None, the current working directory will be used.
- output_namestr | list[str] | None
The name of the generated document. If list[str], the ExcelPrinter will try to print all the with all the Excel templates with corresponding output names. If None, the name of the ‘template’ with a suffix ‘_printed’ will be used.
- include_table_titlesbool, default: False
If True, table headers will be automatically generated from doc_keys_struct. If False, headers are assumed to be already in the template.
- apply_table_bordersbool, default: False
If True, apply outer borders to all table regions.
- border_stylestr, default: “thin”
Border style for tables - “thin”, “medium”, “thick”, “double”, “dashed”, “dashDot”, “dashDotDot”, “hair”, “mediumDashed”, “mediumDashDot”, “mediumDashDotDot”, “slantDashDot” etc. image_size_type: str | dict[str, str], default: “width” The type of the image size. If “width”, the image size will be set to the width of the image (height calculated to maintain aspect ratio). If “height”, the image size will be set to the height of the image (width calculated to maintain aspect ratio). If dict, different key can use different type of image size. If the key is not found, “width” will be used as default. image_size: dict[str, float] | dict[str, list[float]] | None, default: None The size of the image in mm. If dict[str, float], key is the key in the doc_data and the value is the size of the image in mm. If dict[str, list[float]], key is the key in the doc_data and the value is the size for each image in the list in mm. If None, the image size will be as same as its original size.
Notes
process_sheets: str | list[str] | Literal["active", "all"], default: "active" Specifies which sheets to process in the Excel template: - "active": Process only the active sheet (default, backward compatible) - "all": Process all sheets in the workbook - str: Process a specific sheet by name - list[str]: Process specific sheets by their names save_to_gdim: bool, default: False If True, the generated document will also be saved to the gdim file server. token: str | None The token of the user. Must be provided when ``save_to_gdim`` is True. proj_id: int | str | None The id of the gdim project. Must be provided when ``save_to_gdim`` is True. host: str | None The host of the gdim platform.
- execute() PortTypeHint.FilePath | PortTypeHint.FilesPath | PortTypeHint.GdimFile | PortTypeHint.GdimFiles | None
Attributes:
- InputDocData: PortReference[PortTypeHint.DocData]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.FilesPath | PortTypeHint.GdimFile | PortTypeHint.GdimFiles]
- class modules.writers.CreateGdimProjects
Create new gdim projects.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'CreateGdimProjects', auto_run: bool = True, project_infos: PortTypeHint.SingleResult | PortTypeHint.TableData | None = None, raise_error: bool = True, token: str | None = None, host: str | None = None) None
Initialize the CreateGdimProjects object.
Parameters
- project_infosPortTypeHint.SingleResult | PortTypeHint.TableData | None, default: None
The project info of the projects to be created. Can be a SingleResult or a TableData.
Raises
- token
str | None The token of the user.
- host
str | None The host of the gdim platform. Ports
- InputToken
PortTypeHint.Token The token of the user.
- InputProjectInfos
PortTypeHint.SingleResult | PortTypeHint.TableData The project info of the projects to be created. Can be a SingleResult or a TableData.
- OutputSingleResultDict
PortTypeHint.SingleResultDict The project info of the created projects in SingleResultDict format.
- OutputTableData
PortTypeHint.TableData The table data of the created projects in TableData format.
- execute() PortTypeHint.SingleResult | PortTypeHint.SingleResultDict | None
Execute the CreateGdimProjects module.
Returns
- Any
PortTypeHint.SingleResult | PortTypeHint.SingleResultDict | None If only one project is created, returns a SingleResult. If multiple projects are created, returns a SingleResultDict with project IDs as keys.
Attributes:
- InputToken: PortReference[PortTypeHint.Token]
- InputProjectInfos: PortReference[PortTypeHint.SingleResult | PortTypeHint.TableData]
- OutputSingleResultDict: PortReference[PortTypeHint.SingleResult | PortTypeHint.SingleResultDict]
- OutputTableData: PortReference[PortTypeHint.TableData]
- class modules.writers.GdimTableWriter
Write the data of serveral tables in a GDIM project.
Notes
**Updating Existing Records:** To update existing GDIM records, include a ``gdim_id`` column in your TableData: #. When reading from GDIM, set ``keep_gdim_id=True`` in ``GdimTableReader`` to preserve the ID column as ``gdim_id`` #. For new data merged with existing data, use ``MergeGdimTables`` to add the ``gdim_id`` column #. When writing back, ``GdimTableWriter`` automatically renames ``gdim_id`` back to ``id`` for GDIM to recognize and update records Records with ``gdim_id`` will be updated; records without it will be inserted as new.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = 'GdimTableWriter', auto_run: bool = True, data: PortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.GeneralTable | PortTypeHint.NumberTable | None = None, table_names: str | list[str] | None = None, fields_mapping: dict[str, str] | dict[str, dict[str, str]] | None = None, raise_error: bool = True, strict_datetime_validation: bool = True, validation_level: Literal[fast, full] = 'full', auto_convert: bool = False, token: str | None = None, proj_id: str | None = None, host: str | None = None) None
Initialize the GdimTableWriter object.
Parameters
- dataPortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.GeneralTable | PortTypeHint.NumberTable | None
The data to be written to the gdim tables.
- table_namesstr | list[str] | None, default: None
The name or title of the table to be written to. table name will be checked at first, if not found, the title will be checked. If None, for
TableDataandTableCollection, the name of the table in the table data will used. Otherwise, the table name is neccessary. If not None, forTableDataandTableCollection, the table name in the data will be ignored. Iflist, the data should beTableCollectionand has the same length as the data. fields_mapping: dict[str, str] | dict[str, dict[str, str]] | None, default: None The mapping of the fields in the data to the fields in the gdim tables. If dict[str, str], the key can be either the column name or field title in the source data, and the value can be either the field name or field title in the GDIM tables. If dict[str, dict[str, str]], the key is the table name or title, the value is the corresponding field mapping where keys can be source column names or field titles, and values can be GDIM field names or field titles. If the mapping for a field in the data is not defined, the original field name or title will be used. If None, the fields in the data will be written to the gdim tables without any mapping using the original field names or titles.
Raises
- strict_datetime_validation
bool, default: True If True, use regex + datetime parsing validation (slower, more accurate). If False, use regex-only validation (faster, slightly less accurate). Default is True for data quality.
- validation_level
Literal[“fast”, “full”], default: “full”
Validation complexity level
- “fast”
Only vectorized operations + basic type checks (fastest)
- “full”
Complete validation including complex structure checks (slower, most accurate) Default is “full” for maximum data quality.
- auto_convert
bool, default: False If True, coerce column values to match GDIM widget types before validation. This performs safe conversions such as numeric scalars to strings for text fields, datetime values to formatted strings for dateTime fields, and numeric strings to numbers for number fields. Default is False to preserve strict validation behavior.
- token
str | None The token of the user.
- proj_id
str | None The id of the gdim project. If
self.proj_idis not None, theproj_idin InputToken or pipeline’sgdim_proj_idwill be ignored.- host
str | None The host of the gdim platform. Ports
- InputToken
PortTypeHint.Token The token of the user.
- InputData
PortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.GeneralTable | PortTypeHint.NumberTable The data to be written to the gdim tables.
Examples
- {"source_col_name": "target_field_name"} # Column name to field name - {"Source Title": "Target Title"} # Field title to field title - {"source_col": "Target Title"} # Column name to field title - {"Source Title": "target_field"} # Field title to field nameNotes
- If you want to change the ``proj_id`` by InputToken, DO NOT set ``proj_id`` in the constructor or assign value to ``proj_id``, as the ``self.proj_id`` has the highest priority.
Attributes:
- InputToken: PortReference[PortTypeHint.Token]
- InputData: PortReference[PortTypeHint.ResultModel | PortTypeHint.TableData | PortTypeHint.TableCollection | PortTypeHint.GeneralTable | PortTypeHint.NumberTable]
- class modules.writers.MdbWriter
Write the data into a .mdb file.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = 'MdbWriter', auto_run: bool = True, tables: PortTypeHint.TableCollection | PortTypeHint.TableCollectionDict | None = None, mdb_template_file: str | dict | None = None, token: str | None = None, proj_id: int | str | None = None, proj_ids: list[int | str] | None = None, host: str | None = None) None
Initialize the MdbWriter object.
Parameters
- dataPortTypeHint.TableCollection | None
The data to be written to the mdb.
- mdb_template_filestr | dict | None
The mdb template file. If it is a dict, it will be converted to a GdimMinIOFile object. If it is a str, it will be used as the path to the mdb template file.
- tokenstr | None
The token of the user.
- proj_idint | str | None
The id of the gdim project.
- hoststr | None
The host of the gdim platform.
Attributes:
- InputToken: PortReference[PortTypeHint.Token]
- InputTables: PortReference[PortTypeHint.TableCollection | PortTypeHint.TableCollectionDict]
- OutputGdimFile: PortReference[PortTypeHint.GdimFile]
- class modules.writers.TextWriter
Write a plain-text string or JSON object or ResultModel to a file with an arbitrary extension.
The data received on
``InputText``is written to disk as a UTF-8 file. When the input is a``JsonObject``(``dict``or``list``) it is automatically serialised to a JSON string before writing. When the input is a :class:~gdi.dataclass.results.ResultModel, text is built via :meth:~gdi.dataclass.results.ResultModel.to_plain_text(see that method for``result_model_keys``and``result_model_value_separator``behaviour). The file extension defaults to ``"txt"``but can be set to anything (e.g. ``"md"``, ``"json"``, ``"csv"``). When``save_to_gdim``is``True``the file is also uploaded to the GDIM MinIO file server.- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'TextWriter', auto_run: bool = True, text: PortTypeHint.Text | PortTypeHint.JsonObject | ResultModel | None = None, output_dir: str | None = None, output_name: str = 'output', suffix: str = 'txt', encoding: str = 'utf-8', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None, json_indent: int | None = 2, result_model_keys: list[str] | None = None, result_model_value_separator: str = '\n\n') None
Initialise a TextWriter module.
Parameters
- textstr | dict | list | ResultModel | None
The text content (or JSON-serialisable object, or :class:
ResultModel) to write supplied via the``InputText``port.- output_dirstr | None
Directory in which to create the file. The pipeline’s
``workspace``takes priority. Falls back to the current working directory when both are``None``.- output_namestr, default: ``
"output"`` Base name of the output file (without extension).
- suffixstr, default: ``
"txt"`` File extension without the leading dot, e.g. ``
"txt"``, ``"md"``, ``"json"``.- encodingstr, default: ``
"utf-8"`` Text encoding used when writing the file.
- save_to_gdimbool, default:
``False`` When
``True``, the file is also uploaded to the GDIM MinIO file server. Requires a valid token / proj_id (either from the``InputToken``port or the pipeline’s``gdim_state``).- tokenstr | None
User token. Can also be supplied via the pipeline’s
``gdim_state``.- proj_idint | str | None
GDIM project id. Can also be supplied via the pipeline’s
``gdim_state``.- hoststr | None
GDIM platform host. Can also be obtained from the pipeline.
- json_indentint | None, default:
``2`` Indentation level used when serialising a
``JsonObject``input to a JSON string. Pass``None``for compact (no indentation) output. Also applied when embedding``dict``values inside a :class:ResultModelfield.- result_model_keyslist[str] | None, default:
``None`` When
``InputText``is a :class:ResultModel, only these field names or display titles are written, in this order. When``None``, every field whose value is JSON-serialisable (see module logic) is included in model definition order.- result_model_value_separatorstr, default: ``
"\n\n"`` When
``InputText``is a :class:ResultModel, used to join (1) items when a field value is a sequence and (2) the rendered strings of successive fields. Ports- InputTextPortTypeHint.Text | PortTypeHint.JsonObject | PortTypeHint.ResultModel
The text content, JSON-serialisable object, or structured result to write. When a
``JsonObject``(``dict``or``list``) is received it is serialised to a JSON string. When a :class:ResultModelis received it is flattened to plain text as described above.- InputTokenPortTypeHint.Token
User token (optional — see parameter description above).
- OutputFilePortTypeHint.FilePath | PortTypeHint.GdimFile
The saved file path, or the GDIM file object when
``save_to_gdim``is``True``.
- execute() PortTypeHint.FilePath | PortTypeHint.GdimFile | None
Write the input text to a file and optionally upload it to GDIM.
Attributes:
- InputText: PortReference[PortTypeHint.Text | PortTypeHint.JsonObject | PortTypeHint.ResultModel]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.GdimFile]
- class modules.writers.ExportGdimTables
Export all tables’ data of a gdim project in a specified format.
The exported file always contains both the human-readable title and the internal name for every table and field: - **Table identification**: each table's CSV file / Excel sheet is named after its *title* (truncated to 31 characters for Excel). The metadata entry records both the ````name```` and ````title```` so readers can always recover the full title even when the sheet name was truncated. - **Field headers**: row 1 contains field *titles*, row 2 contains field *names*, row 3 contains field *units* (only for ````number```` fields), and data rows start at row 4. - **Metadata**: a ````metadata```` file / sheet stores ````dataTemplateId````, a ````tables```` mapping (keyed by internal name), and a ````tableRelations```` mapping (keyed by internal name).
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'ExportGdimTables', auto_run: bool = True, tables: PortTypeHint.TableCollection | PortTypeHint.TableData | None = None, template_id: PortTypeHint.ResultModel | None = None, format: Literal[gtb, xlsx] = 'gtb', output_dir: str | None = None, output_name: str = 'gdim_tables', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize the ExportGdimTables object.
Parameters
- output_dirstr | None
The directory to save the generated document. The pipeline’s
workspacetakes priority over this value. If both areNone, the current working directory is used.- output_namestr, default: “gdim_tables”
Base name of the output file (without extension).
- save_to_gdimbool, default: False
When
True, the generated file is also uploaded to the GDIM file server. Requires a valid token / proj_id.- tokenstr | None
The user token. Can also be supplied via the pipeline’s
gdim_state.- proj_idint | str | None
The GDIM project id. Can also be supplied via the pipeline’s
gdim_state.- hoststr | None
The host of the gdim platform. Can be get from the
pipeline. Ports- InputTablesPortTypeHint.TableCollection | PortTypeHint.TableData
The tables to be saved.
- InputTemplateIdPortTypeHint.ResultModel
The template id stored in the project information.
- InputTokenPortTypeHint.Token
The user token. Optional — see parameter description above.
- OutputFilePortTypeHint.FilePath | PortTypeHint.GdimFile
The saved file path or GDIM file object.
Attributes:
- InputTables: PortReference[PortTypeHint.TableCollection | PortTypeHint.TableData]
- InputTemplateId: PortReference[PortTypeHint.ResultModel]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.GdimFile]
- class modules.writers.UpdateGdimAppProjectInfo
Update the data of Project Information APP.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str = 'UpdateGdimAppProjectInfo', auto_run: bool = True, update_data: PortTypeHint.SingleResult | PortTypeHint.ResultModel | None = None, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize the UpdateGdimAppProjectInfo object.
Parameters
- update_dataPortTypeHint.SingleResult | PortTypeHint.ResultModel | None
The data of the project information to update. Coordinate system information can also in inlucded in the
update_data. If key of a field is not in the data, the value of the field will be kept unchanged. For projectAddress, here are the keys:projectAddressProvince
projectAddressCity
projectAddressDistrict
projectAddressDetail
- tokenstr | None
The token of the user.
- proj_idint | str | None
The id of the project.
- hoststr | None
The host of the gdim platform.
Notes
For cutomer fields in the project information, both field name or field title is accepted.
Attributes:
- InputToken: PortReference[PortTypeHint.Token]
- InputResultModel: PortReference[PortTypeHint.SingleResult | PortTypeHint.ResultModel]
- OutputResultModel: PortReference[PortTypeHint.ResultModel]
- class modules.writers.BorePlanDrawWriter
Write the input table collection to a .gsc file which can be used for bores plan drawing in KCAD.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = 'ConvertToBorePlanForCad', auto_run: bool = True, tables: PortTypeHint.TableCollection | None = None, proj_info: PortTypeHint.ResultModel | None = None, coordinate_system: PortTypeHint.SingleResult | None = None, name_maps: dict[str, dict[str, str]] | None = None, bore_types_map: dict[str, BoreTypes] | None = None, proj_info_name_map: dict[str, str] | None = None, output_dir: str | Path | None = None, gsc_file_name: str = 'bore_plan_for_cad_draw.gsc', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize a ConvertToBorePlanForCad object.
Parameters
- tablesPortTypeHint.TableCollection | None, default: None
The input table collection containing bore and section line data. Here are the table names:
bore_table : 钻孔一览表
section_line_table : 剖面线表
- proj_infoPortTypeHint.ResultModel | None, default: None
The input ResultModel containing project info data. name_maps: dict[str, dict[str, str]] | None, default: None Mapping of table names and field names between gsc file and the input tables. Key is the field_name in the gsc file and value is the table_name or table_title and field_name or field_title in the input tables.
Examples
{ "table_names": { "bore_table": "actual_bore_table_name", "layer_table": "actual_layer_table_name", "section_line_table": "actual_section_line_table_name", ... }, "field_names": { "bore_table": { "bore_num": "actual_bore_num_field", "x": "actual_x_field", "y": "actual_y_field", "bore_type": "actual_bore_type_field", "top": "actual_top_field", "steady_water_depth": "actual_steady_water_depth_field", }, "layer_table": { "bore_num": "actual_bore_num_field", "depths": "actual_depths_field" }, "section_line_table": { "name": "actual_name_field", "bores": "actual_bores_field", } } } bore_types_map: dict[str, BoreTypes] | None, default: None Mapping from string bore type names to BoreTypes enum. For example: {"鉴别孔": BoreTypes.IdentificationBore, "取土试样钻孔": BoreTypes.SoilSamplingBore} If the map is not specified, will try to compare to the names and titles of BoreTypes automatically. proj_info_name_map: dict[str, str] | None, default: None The mapping of the field_name of the ``geoProfiles.ProjectInfo`` and field_name or field_title of the result model. The key is the field_name in ``geoProfiles.ProjectInfo``. The value is the field_name or field_title from the result model, If the mapping of a key is not provided, the function will try to find the field_name of the result model which is same as the ``geoProfiles.ProjectInfo`` field_name automatically. output_dir: str | Path | None, default: None The directory to save the output gsc file. - 'workspace' of pipeline has priority over the 'output_dir'. - If both 'output_dir' and 'workspace' are None, the current working directory will be used. gsc_file_name: str, default: "bore_plan_for_cad_draw.gsc" The name of the gsc file. If None, the gsc file will not be saved. save_to_gdim: bool, default: False If True, the generated .gsc file will also be saved to the gdim file server. token: str | None The token of the user. Must be provided when ``save_to_gdim`` is True. proj_id: int | str | None The id of the gdim project. Must be provided when ``save_to_gdim`` is True. host: str | None The host of the gdim platform. Ports InputTables: PortTypeHint.TableCollection The input table collection containing bore and section line data. InputProjectInfo: PortTypeHint.ResultModel The input project info. InputCoordinateSystem: PortTypeHint.CoordinateSystem The input coordinate system. InputToken: PortTypeHint.Token The token of the user. OutputFile: PortTypeHint.FilePath | PortTypeHint.GdimFile The output gsc file.
Attributes:
- InputTables: PortReference[PortTypeHint.TableCollection]
- InputProjectInfo: PortReference[PortTypeHint.ResultModel]
- InputCoordinateSystem: PortReference[PortTypeHint.CoordinateSystem]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.GdimFile]
- class modules.writers.BoreLogDrawWriter
Write the input table collection to a .gsc file which can be used for bores log drawing in KCAD.
- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = 'ConvertToBoreForCadDraw', auto_run: bool = True, tables: PortTypeHint.TableCollection | None = None, geo_params_table: PortTypeHint.TableData | None = None, proj_info: PortTypeHint.ResultModel | None = None, name_maps: dict[str, dict[str, str]] | None = None, selected_bores: list[str] | None = None, drawing_scales: dict[str, int] | list[dict[str, str | int]] | int | None = None, proj_info_name_map: dict[str, str] | None = None, sample_types_map: dict[str, int] | None = None, output_dir: str | Path | None = None, gsc_file_name: str = 'bore_for_cad_draw.gsc', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Initialize a ConvertToBoreForCadDraw object.
Parameters
- tablesPortTypeHint.TableCollection | None, default: None
The input table collection containing bore, layer, and test data etc. Here are the table names:
bore_table : 钻孔一览表
layer_table : 地层表
materials_table : 标准地层表
spt_table : 标贯表
cpt_table : 双桥静探表
dpt_table : 动探表
wave_table : 波速表
samples_table : 取样表
soils_test_table : 常规试验表
- geo_params_tablePortTypeHint.TableData | None, default: None
The input table data containing geo parameters data from Gdim App ‘岩土参数建议值表’.
geo_parameters_table : 岩土参数建议值表
- proj_infoPortTypeHint.ResultModel | None, default: None
The input ResultModel containing project info data. name_maps: dict[str, dict[str, str]] | None, default: None Mapping of table names and field names between gsc file and the input tables. Key is the field_name in the gsc file and value is the table_name or table_title and field_name or field_title in the input tables.
Examples
{ "table_names": { "bore_table": "actual_bore_table_name", "layer_table": "actual_layer_table_name", ... }, "field_names": { "bore_table": { "bore_num": "actual_bore_num_field", "x": "actual_x_field", ... }, ... } } selected_bores: list[str] | None, default: None List of bores (input bore numbers) to convert. If None, all bores will be converted. drawing_scales: dict[str, int] | int | None, default: None Drawing scales for bores. If int, it will be used for all bores. If dict, the key is bore number, the value is drawing scale. If list, use the following format - ``[{"bore_num": "num_1", "drawing_scales": 200}, {"bore_num": "num_2", "drawing_scales": 300}]`` proj_info_name_map: dict[str, str] | None, default: None The mapping of the field_name of the ``geoProfiles.ProjectInfo`` and field_name or field_title of the result model. The key is the field_name in ``geoProfiles.ProjectInfo``. The value is the field_name or field_title from the result model, If the mapping of a key is not provided, the function will try to find the field_name of the result model which is same as the ``geoProfiles.ProjectInfo`` field_name automatically. sample_types_map: dict[str, int] | None, default: None Mapping from string sample type names to integer codes. For example: {"厚壁原状": 0, "薄壁原状": 0, "扰动样": 1, "岩石样": 2, "水样": 3} output_dir: str | Path | None, default: None The directory to save the output gsc file. - 'workspace' of pipeline has priority over the 'output_dir'. - If both 'output_dir' and 'workspace' are None, the current working directory will be used. gsc_file_name: str, default: "bore_for_cad_draw.gsc" The name of the gsc file. save_to_gdim: bool, default: False If True, the generated document will also be saved to the gdim file server. token: str | None The token of the user. Must be provided when ``save_to_gdim`` is True. proj_id: int | str | None The id of the gdim project. Must be provided when ``save_to_gdim`` is True. host: str | None The host of the gdim platform.
Attributes:
- InputTables: PortReference[PortTypeHint.TableCollection]
- InputGeoParamsTable: PortReference[PortTypeHint.TableData]
- InputProjectInfo: PortReference[PortTypeHint.ResultModel]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.GdimFile]
- class modules.writers.GeoSectionsWriter
Write geo sections to a .gsc file which can be used for geological section drawing in KCAD.
The geo sections are generated by the
ExportGeoSectionsByBoresmodule.- Inherits from:
PipeModule
Methods:
- __init__(mname: str | None = 'GeoSectionsWriter', auto_run: bool = True, geo_sections: PortTypeHint.GeoSections | None = None, output_dir: str | Path | None = None, gsc_file_name: str = 'geo_sections.gsc', save_to_gdim: bool = False, token: str | None = None, proj_id: int | str | None = None, host: str | None = None) None
Attributes:
- InputGeoSections: PortReference[PortTypeHint.GeoSections]
- InputToken: PortReference[PortTypeHint.Token]
- OutputFile: PortReference[PortTypeHint.FilePath | PortTypeHint.GdimFile]