micantis 1.2.1__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {micantis-1.2.1 → micantis-1.2.2}/PKG-INFO +1 -1
- {micantis-1.2.1 → micantis-1.2.2}/micantis/api_wrapper.py +146 -8
- {micantis-1.2.1 → micantis-1.2.2}/micantis.egg-info/PKG-INFO +1 -1
- {micantis-1.2.1 → micantis-1.2.2}/pyproject.toml +1 -1
- {micantis-1.2.1 → micantis-1.2.2}/LICENSE +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/README.md +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis/__init__.py +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis/utils.py +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis.egg-info/SOURCES.txt +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis.egg-info/dependency_links.txt +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis.egg-info/requires.txt +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/micantis.egg-info/top_level.txt +0 -0
- {micantis-1.2.1 → micantis-1.2.2}/setup.cfg +0 -0
|
@@ -2026,6 +2026,110 @@ class MicantisAPI:
|
|
|
2026
2026
|
cycle, step_kind, step_index)
|
|
2027
2027
|
return action
|
|
2028
2028
|
|
|
2029
|
+
@staticmethod
|
|
2030
|
+
def rename_column(source_column_index, new_name, name=None):
|
|
2031
|
+
"""Build a rename-column action for clean_data (MetadataEdit mode).
|
|
2032
|
+
|
|
2033
|
+
Rename a column's display Name — what graphs, tables, and reports look up
|
|
2034
|
+
by YAxisName. Targets the ORIGINAL source column index; action order does
|
|
2035
|
+
not shift index meaning.
|
|
2036
|
+
|
|
2037
|
+
Parameters
|
|
2038
|
+
----------
|
|
2039
|
+
source_column_index : int
|
|
2040
|
+
0-based index into the ORIGINAL source column list.
|
|
2041
|
+
new_name : str
|
|
2042
|
+
New display name. Preserve exact spacing / punctuation expected by
|
|
2043
|
+
downstream lookups (e.g. "Temp 1 (C)" with two spaces).
|
|
2044
|
+
name : str, optional
|
|
2045
|
+
Descriptive name for this action.
|
|
2046
|
+
"""
|
|
2047
|
+
action = {"$type": "rename",
|
|
2048
|
+
"sourceColumnIndex": int(source_column_index),
|
|
2049
|
+
"newName": new_name}
|
|
2050
|
+
if name is not None:
|
|
2051
|
+
action["name"] = name
|
|
2052
|
+
return action
|
|
2053
|
+
|
|
2054
|
+
@staticmethod
|
|
2055
|
+
def change_column_kind(source_column_index, new_kind, name=None):
|
|
2056
|
+
"""Build a change-column-kind action for clean_data (MetadataEdit mode).
|
|
2057
|
+
|
|
2058
|
+
Change a column's YAxisKind (cycle-tester aux) or ImportItemKind (logger)
|
|
2059
|
+
— controls which kind-based lookups match the column. Targets the ORIGINAL
|
|
2060
|
+
source column index.
|
|
2061
|
+
|
|
2062
|
+
Parameters
|
|
2063
|
+
----------
|
|
2064
|
+
source_column_index : int
|
|
2065
|
+
0-based index into the ORIGINAL source column list.
|
|
2066
|
+
new_kind : str
|
|
2067
|
+
Exact enum value name (e.g. 'Voltage', 'AuxTemperature').
|
|
2068
|
+
name : str, optional
|
|
2069
|
+
Descriptive name for this action.
|
|
2070
|
+
"""
|
|
2071
|
+
action = {"$type": "kind",
|
|
2072
|
+
"sourceColumnIndex": int(source_column_index),
|
|
2073
|
+
"newKind": new_kind}
|
|
2074
|
+
if name is not None:
|
|
2075
|
+
action["name"] = name
|
|
2076
|
+
return action
|
|
2077
|
+
|
|
2078
|
+
@staticmethod
|
|
2079
|
+
def reorder_columns(source_column_indices, name=None):
|
|
2080
|
+
"""Build a reorder-columns action for clean_data (MetadataEdit mode).
|
|
2081
|
+
|
|
2082
|
+
Declarative final column layout: source columns appear in the cleaned
|
|
2083
|
+
output in the order listed; any source index not listed is dropped.
|
|
2084
|
+
Combines drop + reorder in one action. At most one per definition.
|
|
2085
|
+
|
|
2086
|
+
Parameters
|
|
2087
|
+
----------
|
|
2088
|
+
source_column_indices : list[int]
|
|
2089
|
+
Ordered list of 0-based source column indices to keep. Omit an index
|
|
2090
|
+
to drop that column. Example: [0, 1, 3, 4, 5] drops source column 2.
|
|
2091
|
+
name : str, optional
|
|
2092
|
+
Descriptive name for this action.
|
|
2093
|
+
"""
|
|
2094
|
+
action = {"$type": "reorderColumns",
|
|
2095
|
+
"sourceColumnIndices": [int(i) for i in source_column_indices]}
|
|
2096
|
+
if name is not None:
|
|
2097
|
+
action["name"] = name
|
|
2098
|
+
return action
|
|
2099
|
+
|
|
2100
|
+
@staticmethod
|
|
2101
|
+
def edit_logger_step(line=None, lines=None, columns=None, name=None):
|
|
2102
|
+
"""Build an edit-logger-timestep action for clean_data (logger-data analog of modify_step/bulk_modify).
|
|
2103
|
+
|
|
2104
|
+
Edit Column1..Column10 values by 0-based column index on rows matched by
|
|
2105
|
+
``line`` and/or ``lines`` (union). Use on DataLoggerData sources only; for
|
|
2106
|
+
cycle-tester data use modify_step / bulk_modify.
|
|
2107
|
+
|
|
2108
|
+
Parameters
|
|
2109
|
+
----------
|
|
2110
|
+
line : int, optional
|
|
2111
|
+
Single line number to edit.
|
|
2112
|
+
lines : list of (int, int) tuples, optional
|
|
2113
|
+
Line number ranges to edit, e.g. [(100, 200)]. End may be None for open-ended.
|
|
2114
|
+
columns : dict of {int: float}
|
|
2115
|
+
Column edits as {column_index: value}. Column index is 0-based (0-9).
|
|
2116
|
+
name : str, optional
|
|
2117
|
+
Descriptive name for this action.
|
|
2118
|
+
"""
|
|
2119
|
+
if line is None and not lines:
|
|
2120
|
+
raise ValueError("edit_logger_step requires either line or lines.")
|
|
2121
|
+
if not columns:
|
|
2122
|
+
raise ValueError("edit_logger_step requires columns.")
|
|
2123
|
+
action = {"$type": "editLogger"}
|
|
2124
|
+
if name is not None:
|
|
2125
|
+
action["name"] = name
|
|
2126
|
+
if line is not None:
|
|
2127
|
+
action["lineNumber"] = line
|
|
2128
|
+
if lines:
|
|
2129
|
+
action["lineNumberRanges"] = _ranges(lines)
|
|
2130
|
+
action["columns"] = [{"columnIndex": int(k), "value": float(v)} for k, v in columns.items()]
|
|
2131
|
+
return action
|
|
2132
|
+
|
|
2029
2133
|
def clean_data(self,
|
|
2030
2134
|
source_ids: list,
|
|
2031
2135
|
mode: str = 'CycleAutoFixup',
|
|
@@ -2044,14 +2148,19 @@ class MicantisAPI:
|
|
|
2044
2148
|
source_ids : list of str
|
|
2045
2149
|
List of cell data IDs (GUIDs) to clean.
|
|
2046
2150
|
mode : str, optional
|
|
2047
|
-
Cleaning mode. One of 'CycleAutoFixup', 'FilterCycles', 'Parametric'.
|
|
2048
|
-
Default: 'CycleAutoFixup'.
|
|
2151
|
+
Cleaning mode. One of 'CycleAutoFixup', 'FilterCycles', 'Parametric', 'MetadataEdit'.
|
|
2152
|
+
Default: 'CycleAutoFixup'. When ``actions`` is provided and mode is still the default,
|
|
2153
|
+
it auto-sets to 'Parametric'. For 'MetadataEdit', pass mode explicitly.
|
|
2049
2154
|
filter_cycles_definition : dict, optional
|
|
2050
2155
|
Required when mode is 'FilterCycles'. Definition for filtering cycles.
|
|
2051
2156
|
actions : list, optional
|
|
2052
|
-
|
|
2053
|
-
api.
|
|
2054
|
-
|
|
2157
|
+
For Parametric mode: list of dicts from api.remove_steps(), api.modify_step(),
|
|
2158
|
+
api.bulk_modify(), api.edit_logger_step().
|
|
2159
|
+
For MetadataEdit mode: list of dicts from api.rename_column(),
|
|
2160
|
+
api.change_column_kind(), api.reorder_columns().
|
|
2161
|
+
Actions are applied in the order given.
|
|
2162
|
+
|
|
2163
|
+
Parametric example (cycle-tester)::
|
|
2055
2164
|
|
|
2056
2165
|
api.clean_data(
|
|
2057
2166
|
source_ids=[id],
|
|
@@ -2061,6 +2170,29 @@ class MicantisAPI:
|
|
|
2061
2170
|
api.bulk_modify(lines=[(100, 5000)], cycle=1),
|
|
2062
2171
|
]
|
|
2063
2172
|
)
|
|
2173
|
+
|
|
2174
|
+
Parametric example (DataLoggerData)::
|
|
2175
|
+
|
|
2176
|
+
api.clean_data(
|
|
2177
|
+
source_ids=[logger_id],
|
|
2178
|
+
actions=[
|
|
2179
|
+
api.remove_steps(lines=[(1, 3)]),
|
|
2180
|
+
api.edit_logger_step(line=10, columns={0: 1.5}),
|
|
2181
|
+
]
|
|
2182
|
+
)
|
|
2183
|
+
|
|
2184
|
+
MetadataEdit example (rename + drop — works on both CT and logger)::
|
|
2185
|
+
|
|
2186
|
+
api.clean_data(
|
|
2187
|
+
source_ids=[id],
|
|
2188
|
+
mode='MetadataEdit',
|
|
2189
|
+
actions=[
|
|
2190
|
+
api.rename_column(source_column_index=3, new_name='Temp 1 (C)'),
|
|
2191
|
+
api.rename_column(source_column_index=4, new_name='Temp 2 (C)'),
|
|
2192
|
+
api.rename_column(source_column_index=5, new_name='Temp 3 (C)'),
|
|
2193
|
+
api.reorder_columns([0, 1, 3, 4, 5]), # drops source column 2
|
|
2194
|
+
]
|
|
2195
|
+
)
|
|
2064
2196
|
allow_async : bool, optional
|
|
2065
2197
|
If True, runs asynchronously and returns job ID. Default: False.
|
|
2066
2198
|
timeout : int, optional
|
|
@@ -2073,7 +2205,8 @@ class MicantisAPI:
|
|
|
2073
2205
|
If allow_async is True: {'job_id': str}
|
|
2074
2206
|
Returns None if an error occurs.
|
|
2075
2207
|
"""
|
|
2076
|
-
if
|
|
2208
|
+
# Auto-set mode only if the caller left the default; preserves explicit 'MetadataEdit' etc.
|
|
2209
|
+
if actions is not None and mode == 'CycleAutoFixup':
|
|
2077
2210
|
mode = 'Parametric'
|
|
2078
2211
|
|
|
2079
2212
|
try:
|
|
@@ -2104,8 +2237,10 @@ class MicantisAPI:
|
|
|
2104
2237
|
|
|
2105
2238
|
if mode == 'Parametric' and not actions:
|
|
2106
2239
|
raise ValueError("actions is required when mode is 'Parametric'.")
|
|
2240
|
+
if mode == 'MetadataEdit' and not actions:
|
|
2241
|
+
raise ValueError("actions is required when mode is 'MetadataEdit'.")
|
|
2107
2242
|
|
|
2108
|
-
_mode_map = {'CycleAutoFixup': 1, 'Parametric': 2, 'FilterCycles': 4}
|
|
2243
|
+
_mode_map = {'CycleAutoFixup': 1, 'Parametric': 2, 'FilterCycles': 4, 'MetadataEdit': 5}
|
|
2109
2244
|
if mode not in _mode_map:
|
|
2110
2245
|
raise ValueError(f"mode must be one of {list(_mode_map)}, got '{mode}'")
|
|
2111
2246
|
|
|
@@ -2117,7 +2252,10 @@ class MicantisAPI:
|
|
|
2117
2252
|
if filter_cycles_definition is not None:
|
|
2118
2253
|
payload["filterCyclesDefinition"] = filter_cycles_definition
|
|
2119
2254
|
if actions is not None:
|
|
2120
|
-
|
|
2255
|
+
if mode == 'MetadataEdit':
|
|
2256
|
+
payload["metadataEditDefinition"] = {"actions": actions}
|
|
2257
|
+
else:
|
|
2258
|
+
payload["parametricDefinition"] = {"actions": actions}
|
|
2121
2259
|
|
|
2122
2260
|
url = f"{self.service_url}/publicapi/v1/data/clean"
|
|
2123
2261
|
if allow_async:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|