code-loader 1.0.179.dev1__tar.gz → 1.0.180.dev0__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.
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/PKG-INFO +1 -1
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/datasetclasses.py +9 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/responsedataclasses.py +7 -0
- code_loader-1.0.180.dev0/code_loader/contract/sim_config.py +92 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/inner_leap_binder/leapbinder.py +14 -1
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/inner_leap_binder/leapbinder_decorators.py +62 -14
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/leaploader.py +22 -2
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/pyproject.toml +1 -1
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/LICENSE +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/README.md +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/utils.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/visualizers/default_visualizers.py +0 -0
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/datasetclasses.py
RENAMED
|
@@ -9,6 +9,7 @@ from code_loader.contract.enums import DataStateType, DataStateEnum, LeapDataTyp
|
|
|
9
9
|
MetricDirection, DatasetMetadataType
|
|
10
10
|
from code_loader.contract.visualizer_classes import LeapImage, LeapText, LeapGraph, LeapHorizontalBar, \
|
|
11
11
|
LeapTextMask, LeapImageMask, LeapImageWithBBox, LeapImageWithHeatmap, LeapVideo
|
|
12
|
+
from code_loader.contract.sim_config import SimConfig
|
|
12
13
|
|
|
13
14
|
custom_latent_space_attribute = "custom_latent_space"
|
|
14
15
|
|
|
@@ -252,6 +253,13 @@ class CustomLayerHandler:
|
|
|
252
253
|
use_custom_latent_space: bool = False
|
|
253
254
|
|
|
254
255
|
|
|
256
|
+
@dataclass
|
|
257
|
+
class SimulationInstance:
|
|
258
|
+
name: str
|
|
259
|
+
function: Callable[..., Any]
|
|
260
|
+
sim_config: SimConfig
|
|
261
|
+
|
|
262
|
+
|
|
255
263
|
@dataclass
|
|
256
264
|
class DatasetIntegrationSetup:
|
|
257
265
|
preprocess: Optional[PreprocessHandler] = None
|
|
@@ -267,6 +275,7 @@ class DatasetIntegrationSetup:
|
|
|
267
275
|
instance_metrics: List[InstanceMetricHandler] = field(default_factory=list)
|
|
268
276
|
custom_layers: Dict[str, CustomLayerHandler] = field(default_factory=dict)
|
|
269
277
|
custom_latent_space: Optional[CustomLatentSpaceHandler] = None
|
|
278
|
+
simulations: List[SimulationInstance] = field(default_factory=list)
|
|
270
279
|
|
|
271
280
|
|
|
272
281
|
@dataclass
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/responsedataclasses.py
RENAMED
|
@@ -69,6 +69,12 @@ class PredictionTypeInstance:
|
|
|
69
69
|
channel_dim: int
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
@dataclass
|
|
73
|
+
class SimulationSetupInstance:
|
|
74
|
+
name: str
|
|
75
|
+
sim_config: Dict[str, Any]
|
|
76
|
+
|
|
77
|
+
|
|
72
78
|
@dataclass
|
|
73
79
|
class DatasetSetup:
|
|
74
80
|
preprocess: DatasetPreprocess
|
|
@@ -79,6 +85,7 @@ class DatasetSetup:
|
|
|
79
85
|
prediction_types: List[PredictionTypeInstance]
|
|
80
86
|
custom_losses: List[CustomLossInstance]
|
|
81
87
|
metrics: List[MetricInstance] = field(default_factory=list)
|
|
88
|
+
simulations: List[SimulationSetupInstance] = field(default_factory=list)
|
|
82
89
|
|
|
83
90
|
|
|
84
91
|
@dataclass
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any, Dict, List, Union
|
|
3
|
+
|
|
4
|
+
from code_loader.contract.enums import DatasetMetadataType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class FloatBounds:
|
|
9
|
+
min: float
|
|
10
|
+
max: float
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class IntBounds:
|
|
15
|
+
min: int
|
|
16
|
+
max: int
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class CategoricalBounds:
|
|
21
|
+
values: List[str]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class SimParamConfig:
|
|
26
|
+
type: DatasetMetadataType
|
|
27
|
+
bounds: Union[FloatBounds, IntBounds, CategoricalBounds]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
SimConfig = Dict[str, SimParamConfig]
|
|
31
|
+
|
|
32
|
+
PARAM_TYPE_MAP = {
|
|
33
|
+
float: DatasetMetadataType.float,
|
|
34
|
+
int: DatasetMetadataType.int,
|
|
35
|
+
str: DatasetMetadataType.string,
|
|
36
|
+
"float": DatasetMetadataType.float,
|
|
37
|
+
"int": DatasetMetadataType.int,
|
|
38
|
+
"str": DatasetMetadataType.string,
|
|
39
|
+
"string": DatasetMetadataType.string,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _parse_bounds(name: str, metadata_type: DatasetMetadataType, bounds_raw: Dict[str, Any]) -> Union[FloatBounds, IntBounds, CategoricalBounds]:
|
|
44
|
+
if metadata_type in (DatasetMetadataType.float, DatasetMetadataType.int):
|
|
45
|
+
if "min" not in bounds_raw or "max" not in bounds_raw:
|
|
46
|
+
raise ValueError(
|
|
47
|
+
f"Parameter '{name}' bounds must have 'min' and 'max' for numeric type."
|
|
48
|
+
)
|
|
49
|
+
if bounds_raw["min"] >= bounds_raw["max"]:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
f"Parameter '{name}': min ({bounds_raw['min']}) must be < max ({bounds_raw['max']})."
|
|
52
|
+
)
|
|
53
|
+
if metadata_type == DatasetMetadataType.float:
|
|
54
|
+
return FloatBounds(min=float(bounds_raw["min"]), max=float(bounds_raw["max"]))
|
|
55
|
+
return IntBounds(min=int(bounds_raw["min"]), max=int(bounds_raw["max"]))
|
|
56
|
+
|
|
57
|
+
if metadata_type == DatasetMetadataType.string:
|
|
58
|
+
if "values" not in bounds_raw:
|
|
59
|
+
raise ValueError(
|
|
60
|
+
f"Parameter '{name}' bounds must have 'values' for string type."
|
|
61
|
+
)
|
|
62
|
+
if not bounds_raw["values"]:
|
|
63
|
+
raise ValueError(f"Parameter '{name}' 'values' must not be empty.")
|
|
64
|
+
return CategoricalBounds(values=list(bounds_raw["values"]))
|
|
65
|
+
|
|
66
|
+
raise ValueError(f"Parameter '{name}' has unsupported metadata type: {metadata_type}.")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def parse_sim_config(raw: Dict[str, Any]) -> SimConfig:
|
|
70
|
+
if not raw:
|
|
71
|
+
raise ValueError("sim_config must have at least one parameter.")
|
|
72
|
+
|
|
73
|
+
result: SimConfig = {}
|
|
74
|
+
for name, param in raw.items():
|
|
75
|
+
if "type" not in param:
|
|
76
|
+
raise ValueError(f"Parameter '{name}' missing 'type'.")
|
|
77
|
+
if param["type"] not in PARAM_TYPE_MAP:
|
|
78
|
+
raise ValueError(
|
|
79
|
+
f"Parameter '{name}' has unsupported type '{param['type']}'. "
|
|
80
|
+
f"Supported: float, int, str (or string)."
|
|
81
|
+
)
|
|
82
|
+
metadata_type = PARAM_TYPE_MAP[param["type"]]
|
|
83
|
+
|
|
84
|
+
if "bounds" not in param:
|
|
85
|
+
raise ValueError(f"Parameter '{name}' missing 'bounds'.")
|
|
86
|
+
|
|
87
|
+
result[name] = SimParamConfig(
|
|
88
|
+
type=metadata_type,
|
|
89
|
+
bounds=_parse_bounds(name, metadata_type, param["bounds"]),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return result
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
@@ -12,7 +12,8 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
|
|
|
12
12
|
CustomCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, LeapData, \
|
|
13
13
|
CustomMultipleReturnCallableInterfaceMultiArgs, DatasetBaseHandler, custom_latent_space_attribute, \
|
|
14
14
|
RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse, \
|
|
15
|
-
ElementInstanceMasksHandler, InstanceCallableInterface, CustomLatentSpaceHandler, InstanceMetricHandler
|
|
15
|
+
ElementInstanceMasksHandler, InstanceCallableInterface, CustomLatentSpaceHandler, InstanceMetricHandler, \
|
|
16
|
+
SimulationInstance
|
|
16
17
|
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
|
17
18
|
from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
|
|
18
19
|
from code_loader.contract.responsedataclasses import DatasetTestResultPayload, LeapAnalysisConfiguration
|
|
@@ -20,6 +21,7 @@ from code_loader.contract.visualizer_classes import map_leap_data_type_to_visual
|
|
|
20
21
|
from code_loader.default_losses import loss_name_to_function
|
|
21
22
|
from code_loader.default_metrics import metrics_names_to_functions_and_direction
|
|
22
23
|
from code_loader.utils import to_numpy_return_wrapper, get_shape, to_numpy_return_masks_wrapper
|
|
24
|
+
from code_loader.contract.sim_config import parse_sim_config
|
|
23
25
|
from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
24
26
|
default_graph_visualizer, \
|
|
25
27
|
default_image_visualizer, default_horizontal_bar_visualizer, default_word_visualizer, \
|
|
@@ -219,6 +221,17 @@ class LeapBinder:
|
|
|
219
221
|
"""
|
|
220
222
|
self.setup_container.unlabeled_data_preprocess = UnlabeledDataPreprocessHandler(function)
|
|
221
223
|
|
|
224
|
+
def set_simulation(self, function: Callable[..., Any], name: str, sim_config_raw: Dict[str, Any]) -> None:
|
|
225
|
+
for sim in self.setup_container.simulations:
|
|
226
|
+
if sim.name == name:
|
|
227
|
+
raise Exception(
|
|
228
|
+
f"Simulation with name '{name}' already exists. Please choose another."
|
|
229
|
+
)
|
|
230
|
+
sim_config = parse_sim_config(sim_config_raw)
|
|
231
|
+
self.setup_container.simulations.append(
|
|
232
|
+
SimulationInstance(name=name, function=function, sim_config=sim_config)
|
|
233
|
+
)
|
|
234
|
+
|
|
222
235
|
def set_input(self, function: SectionCallableInterface, name: str, channel_dim: int = -1) -> None:
|
|
223
236
|
"""
|
|
224
237
|
Set the input handler function.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# mypy: ignore-errors
|
|
2
|
+
import inspect
|
|
2
3
|
import os
|
|
3
4
|
import warnings
|
|
4
5
|
import logging
|
|
@@ -28,10 +29,6 @@ from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, Le
|
|
|
28
29
|
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
|
|
29
30
|
from code_loader.mixpanel_tracker import clear_integration_events, AnalyticsEvent, emit_integration_event_once
|
|
30
31
|
|
|
31
|
-
import inspect
|
|
32
|
-
import functools
|
|
33
|
-
from pathlib import Path
|
|
34
|
-
|
|
35
32
|
_called_from_inside_tl_decorator = 0
|
|
36
33
|
_called_from_inside_tl_integration_test_decorator = False
|
|
37
34
|
_call_from_tl_platform = os.environ.get('IS_TENSORLEAP_PLATFORM') == 'true'
|
|
@@ -77,6 +74,13 @@ def store_warning_by_param(
|
|
|
77
74
|
_PARAM_DEFAULT_DOCS[param_name] = link_to_docs
|
|
78
75
|
|
|
79
76
|
|
|
77
|
+
def store_general_warning(*, key: tuple, message: str, link_to_docs: Optional[str] = None) -> None:
|
|
78
|
+
if key in _STORED_WARNING_KEYS:
|
|
79
|
+
return
|
|
80
|
+
_STORED_WARNING_KEYS.add(key)
|
|
81
|
+
_STORED_WARNINGS.append({"message": message, "link_to_docs": link_to_docs})
|
|
82
|
+
|
|
83
|
+
|
|
80
84
|
def _get_param_default_warnings() -> Dict[str, Dict[str, Any]]:
|
|
81
85
|
out: Dict[str, Dict[str, Any]] = {}
|
|
82
86
|
for p, funcs in _PARAM_DEFAULT_FUNCS.items():
|
|
@@ -1226,8 +1230,9 @@ def tensorleap_metadata(
|
|
|
1226
1230
|
def _validate_result(result):
|
|
1227
1231
|
supported_result_types = (type(None), int, str, bool, float, dict, np.floating,
|
|
1228
1232
|
np.bool_, np.unsignedinteger, np.signedinteger, np.integer)
|
|
1229
|
-
|
|
1230
|
-
|
|
1233
|
+
if isinstance(result, tuple):
|
|
1234
|
+
validate_output_structure(result, func_name=user_function.__name__,
|
|
1235
|
+
expected_type_name=supported_result_types)
|
|
1231
1236
|
assert isinstance(result, supported_result_types), \
|
|
1232
1237
|
(f'{user_function.__name__}() validation failed: '
|
|
1233
1238
|
f'Unsupported return type. Got {type(result)}. should be any of {str(supported_result_types)}')
|
|
@@ -1295,17 +1300,17 @@ def tensorleap_custom_latent_space():
|
|
|
1295
1300
|
(f'tensorleap_custom_latent_space validation failed: '
|
|
1296
1301
|
f'The return type should be a numpy array. Got {type(result)}.')
|
|
1297
1302
|
if result.ndim > 1:
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
warnings.warn(
|
|
1303
|
+
flat_dim = int(np.prod(result.shape))
|
|
1304
|
+
store_general_warning(
|
|
1305
|
+
key=("tensorleap_custom_latent_space_flatten", tuple(result.shape)),
|
|
1306
|
+
message=(
|
|
1303
1307
|
f"tensorleap_custom_latent_space returned per-sample shape {tuple(result.shape)} "
|
|
1304
1308
|
f"(ndim={result.ndim}). Tensorleap assumes per-sample shape (d, ...) and will "
|
|
1305
1309
|
f"flatten to ({flat_dim},) before downstream visualization and clustering. "
|
|
1306
1310
|
f"If you want a different aggregation (e.g. global average pooling), do it "
|
|
1307
1311
|
f"inside your function."
|
|
1308
|
-
)
|
|
1312
|
+
),
|
|
1313
|
+
)
|
|
1309
1314
|
|
|
1310
1315
|
def inner_without_validate(sample_id, preprocess_response):
|
|
1311
1316
|
global _called_from_inside_tl_decorator
|
|
@@ -1393,6 +1398,43 @@ def tensorleap_preprocess():
|
|
|
1393
1398
|
return decorating_function
|
|
1394
1399
|
|
|
1395
1400
|
|
|
1401
|
+
def tensorleap_simulation(name: str, sim_params: dict):
|
|
1402
|
+
def decorating_function(user_function: Callable):
|
|
1403
|
+
sig = inspect.signature(user_function)
|
|
1404
|
+
func_params = set(sig.parameters.keys())
|
|
1405
|
+
expected_params = set(sim_params.keys()) | {"N"}
|
|
1406
|
+
|
|
1407
|
+
missing = expected_params - func_params
|
|
1408
|
+
if missing:
|
|
1409
|
+
raise Exception(
|
|
1410
|
+
f"{user_function.__name__}() registration failed: "
|
|
1411
|
+
f"Missing required parameters: {missing}. "
|
|
1412
|
+
f"Function must accept all sim_params params plus 'N'."
|
|
1413
|
+
)
|
|
1414
|
+
|
|
1415
|
+
extra = func_params - expected_params - {"seed"}
|
|
1416
|
+
if extra:
|
|
1417
|
+
raise Exception(
|
|
1418
|
+
f"{user_function.__name__}() registration failed: "
|
|
1419
|
+
f"Unexpected parameters: {extra}. "
|
|
1420
|
+
f"Function must only accept sim_params params plus 'N' and optionally 'seed'."
|
|
1421
|
+
)
|
|
1422
|
+
|
|
1423
|
+
leap_binder.set_simulation(user_function, name, sim_params)
|
|
1424
|
+
|
|
1425
|
+
def inner(*args, **kwargs):
|
|
1426
|
+
result = user_function(*args, **kwargs)
|
|
1427
|
+
assert isinstance(result, PreprocessResponse), (
|
|
1428
|
+
f"{user_function.__name__}() validation failed: "
|
|
1429
|
+
f"Expected return type PreprocessResponse. Got {type(result).__name__}."
|
|
1430
|
+
)
|
|
1431
|
+
return result
|
|
1432
|
+
|
|
1433
|
+
return inner
|
|
1434
|
+
|
|
1435
|
+
return decorating_function
|
|
1436
|
+
|
|
1437
|
+
|
|
1396
1438
|
def tensorleap_element_instance_preprocess(
|
|
1397
1439
|
instance_length_encoder: InstanceLengthCallableInterface, instance_mask_encoder: InstanceCallableInterface):
|
|
1398
1440
|
def decorating_function(user_function: Callable[[], List[PreprocessResponse]]):
|
|
@@ -1989,7 +2031,8 @@ def tensorleap_status_table():
|
|
|
1989
2031
|
|
|
1990
2032
|
def _print_param_default_warnings():
|
|
1991
2033
|
data = _get_param_default_warnings()
|
|
1992
|
-
|
|
2034
|
+
stored = _get_stored_warnings()
|
|
2035
|
+
if not data and not stored:
|
|
1993
2036
|
return
|
|
1994
2037
|
|
|
1995
2038
|
print("\nWarnings (Default use. It is recommended to set values explicitly):")
|
|
@@ -2003,7 +2046,12 @@ def tensorleap_status_table():
|
|
|
2003
2046
|
print(
|
|
2004
2047
|
f" ⚠️ Parameter '{param_name}' defaults to {dv} in the following functions: [{funcs}]. "
|
|
2005
2048
|
f"For more information, check {docs_part}")
|
|
2006
|
-
|
|
2049
|
+
for w in stored:
|
|
2050
|
+
docs_link = w.get("link_to_docs")
|
|
2051
|
+
docs_part = f" {_link(docs_link)}" if docs_link else ""
|
|
2052
|
+
print(f" ⚠️ {w['message']}{docs_part}")
|
|
2053
|
+
if data:
|
|
2054
|
+
print("\nIf this isn’t the intended behaviour, set them explicitly.")
|
|
2007
2055
|
|
|
2008
2056
|
def _print_table():
|
|
2009
2057
|
_print_param_default_warnings()
|
|
@@ -22,13 +22,22 @@ from code_loader.contract.exceptions import DatasetScriptException
|
|
|
22
22
|
from code_loader.contract.responsedataclasses import DatasetIntegParseResult, DatasetTestResultPayload, \
|
|
23
23
|
DatasetPreprocess, DatasetSetup, DatasetInputInstance, DatasetOutputInstance, DatasetMetadataInstance, \
|
|
24
24
|
VisualizerInstance, PredictionTypeInstance, ModelSetup, CustomLayerInstance, MetricInstance, CustomLossInstance, \
|
|
25
|
-
EngineFileContract
|
|
25
|
+
EngineFileContract, SimulationSetupInstance
|
|
26
|
+
from code_loader.contract.sim_config import FloatBounds, IntBounds, CategoricalBounds
|
|
26
27
|
from code_loader.inner_leap_binder import global_leap_binder
|
|
27
28
|
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
|
|
28
29
|
from code_loader.leaploaderbase import LeapLoaderBase
|
|
29
30
|
from code_loader.utils import get_root_exception_file_and_line_number, get_metadata_type_from_variable
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
def _serialize_sim_bounds(bounds) -> dict:
|
|
34
|
+
if isinstance(bounds, (FloatBounds, IntBounds)):
|
|
35
|
+
return {"min": bounds.min, "max": bounds.max}
|
|
36
|
+
if isinstance(bounds, CategoricalBounds):
|
|
37
|
+
return {"values": bounds.values}
|
|
38
|
+
raise ValueError(f"Unknown bounds type: {type(bounds)}")
|
|
39
|
+
|
|
40
|
+
|
|
32
41
|
class LeapLoader(LeapLoaderBase):
|
|
33
42
|
def __init__(self, code_path: str, code_entry_name: str):
|
|
34
43
|
super().__init__(code_path, code_entry_name)
|
|
@@ -454,9 +463,20 @@ class LeapLoader(LeapLoaderBase):
|
|
|
454
463
|
metric_inst = MetricInstance(metric.metric_handler_data.name, metric.metric_handler_data.arg_names)
|
|
455
464
|
metrics.append(metric_inst)
|
|
456
465
|
|
|
466
|
+
simulations = []
|
|
467
|
+
for sim in setup.simulations:
|
|
468
|
+
sim_config_serialized = {
|
|
469
|
+
name: {
|
|
470
|
+
"type": param.type.value,
|
|
471
|
+
"bounds": _serialize_sim_bounds(param.bounds),
|
|
472
|
+
}
|
|
473
|
+
for name, param in sim.sim_config.items()
|
|
474
|
+
}
|
|
475
|
+
simulations.append(SimulationSetupInstance(name=sim.name, sim_config=sim_config_serialized))
|
|
476
|
+
|
|
457
477
|
return DatasetSetup(preprocess=dataset_preprocess, inputs=inputs, outputs=ground_truths,
|
|
458
478
|
metadata=metadata_instances, visualizers=visualizers, prediction_types=prediction_types,
|
|
459
|
-
custom_losses=custom_losses, metrics=metrics)
|
|
479
|
+
custom_losses=custom_losses, metrics=metrics, simulations=simulations)
|
|
460
480
|
|
|
461
481
|
def get_model_setup_response(self) -> ModelSetup:
|
|
462
482
|
setup = global_leap_binder.setup_container
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/contract/visualizer_classes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/cli_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/experiment_api/experiment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/inner_leap_binder/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/__init__.py
RENAMED
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/plot_functions.py
RENAMED
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/plot_functions/visualize.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.179.dev1 → code_loader-1.0.180.dev0}/code_loader/visualizers/default_visualizers.py
RENAMED
|
File without changes
|