iapytoo 0.0.6.dev2__tar.gz → 0.0.6.dev3__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.
Potentially problematic release.
This version of iapytoo might be problematic. Click here for more details.
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/PKG-INFO +1 -1
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/_version.py +2 -2
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo.egg-info/PKG-INFO +1 -1
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo.egg-info/SOURCES.txt +1 -0
- iapytoo-0.0.6.dev3/tests/test_factories.py +127 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/.github/workflows/python-app.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/.gitignore +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/LICENSE +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/MANIFEST.in +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/README.md +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/dockers/Dockerfile +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/dockers/Readme.md +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/dockers/docker-compose.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/dockers/requirements.txt +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/dockers/run-python.sh +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/config_infer.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/config_mnist.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/config_wgan.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/mlflow_infer.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/mnist.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/mnist_infer.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/wgan_mnist.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/examples/zipped_runs/selected_runs.zip +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/dataset/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/dataset/scaling.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/metrics/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/metrics/collection.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/metrics/distrib.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/metrics/metric.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/metrics/predefined.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/predictions/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/predictions/feature.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/predictions/plotters.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/predictions/predictors.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/predictions/types.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/checkpoint.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/context.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/factories.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/inference.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/logger.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/loss.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/mlflow_model.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/training.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/valuator.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/train/wgan.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/__init__.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/arguments.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/cf/config.json +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/cf/config.yml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/cf/config_test.json +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/config.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/display.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/iterative_mean.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/model_config.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/singleton.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/time_utils.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo/utils/timer.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo.egg-info/dependency_links.txt +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/iapytoo.egg-info/top_level.txt +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/mlflow/relocate_mlruns.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/mlflow/zip_selected_runs.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/pyproject.toml +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/requirements.txt +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/setup.cfg +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/tests/test_config.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/tests/test_dataset.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/tests/test_metrics.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/tests/test_model.py +0 -0
- {iapytoo-0.0.6.dev2 → iapytoo-0.0.6.dev3}/tests/test_scaling.py +0 -0
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '0.0.6.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 0, 6, '
|
|
20
|
+
__version__ = version = '0.0.6.dev3'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 0, 6, 'dev3')
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
import torch
|
|
3
|
+
from unittest.mock import MagicMock, patch
|
|
4
|
+
from iapytoo.train.factories import (
|
|
5
|
+
Model,
|
|
6
|
+
Optimizer,
|
|
7
|
+
Factory,
|
|
8
|
+
OptimizerError,
|
|
9
|
+
ModelError,
|
|
10
|
+
SchedulerError,
|
|
11
|
+
MetricError
|
|
12
|
+
)
|
|
13
|
+
from iapytoo.utils.config import Config, ConfigFactory
|
|
14
|
+
|
|
15
|
+
import torch.nn as nn
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestFactory(unittest.TestCase):
|
|
19
|
+
def setUp(self):
|
|
20
|
+
self.factory = Factory()
|
|
21
|
+
self.mock_model = MagicMock(spec=Model)
|
|
22
|
+
self.mock_config = MagicMock(spec=Config)
|
|
23
|
+
|
|
24
|
+
self.config_data = {
|
|
25
|
+
"project": "iapytoo",
|
|
26
|
+
"run": "test_run",
|
|
27
|
+
"sensors": "sensor_1",
|
|
28
|
+
"model": {
|
|
29
|
+
"model": "CNN"
|
|
30
|
+
},
|
|
31
|
+
"dataset": {
|
|
32
|
+
"path": "dummy_path",
|
|
33
|
+
"batch_size": 32
|
|
34
|
+
},
|
|
35
|
+
"training": {
|
|
36
|
+
"learning_rate": 0.001,
|
|
37
|
+
"loss": "mse",
|
|
38
|
+
"optimizer": "adam",
|
|
39
|
+
"scheduler": "step"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def test_create_loss(self):
|
|
44
|
+
loss = self.factory.create_loss("mse")
|
|
45
|
+
self.assertIsInstance(loss, nn.MSELoss)
|
|
46
|
+
|
|
47
|
+
with self.assertRaises(Exception):
|
|
48
|
+
self.factory.create_loss("unknown_loss")
|
|
49
|
+
|
|
50
|
+
def test_create_scheduler(self):
|
|
51
|
+
config_data = self.config_data
|
|
52
|
+
config_data["training"]["gamma"] = 0.1
|
|
53
|
+
config_data["training"]["step_size"] = 10
|
|
54
|
+
|
|
55
|
+
self.mock_config = ConfigFactory.from_args(config_data)
|
|
56
|
+
|
|
57
|
+
param1 = torch.tensor([1.0], requires_grad=True)
|
|
58
|
+
param2 = torch.tensor([2.0], requires_grad=True)
|
|
59
|
+
parameters = [param1, param2]
|
|
60
|
+
mock_optimizer = MagicMock(torch.optim.Adam(parameters))
|
|
61
|
+
|
|
62
|
+
scheduler = self.factory.create_scheduler(
|
|
63
|
+
"step", mock_optimizer, self.mock_config)
|
|
64
|
+
self.assertIsNotNone(scheduler.lr_scheduler)
|
|
65
|
+
|
|
66
|
+
with self.assertRaises(SchedulerError):
|
|
67
|
+
self.factory.create_scheduler(
|
|
68
|
+
"unknown_scheduler", mock_optimizer, self.mock_config)
|
|
69
|
+
|
|
70
|
+
def test_create_optimizer(self):
|
|
71
|
+
config_data = self.config_data
|
|
72
|
+
config_data["training"]["learning_rate"] = 0.001
|
|
73
|
+
config_data["training"]["weight_decay"] = None
|
|
74
|
+
config_data["training"]["betas"] = None
|
|
75
|
+
self.mock_config = ConfigFactory.from_args(config_data)
|
|
76
|
+
|
|
77
|
+
# Créez un MagicMock pour simuler un nn.Module
|
|
78
|
+
mock_module = MagicMock(spec=nn.Module)
|
|
79
|
+
param1 = torch.tensor([1.0], requires_grad=True)
|
|
80
|
+
param2 = torch.tensor([2.0], requires_grad=True)
|
|
81
|
+
mock_module.parameters.return_value = [param1, param2]
|
|
82
|
+
|
|
83
|
+
optimizer = self.factory.create_optimizer(
|
|
84
|
+
"adam", mock_module, self.mock_config)
|
|
85
|
+
self.assertIsNotNone(optimizer.torch_optimizer)
|
|
86
|
+
|
|
87
|
+
with self.assertRaises(OptimizerError):
|
|
88
|
+
self.factory.create_optimizer(
|
|
89
|
+
"unknown_optimizer", self.mock_model, self.mock_config)
|
|
90
|
+
|
|
91
|
+
def test_create_model(self):
|
|
92
|
+
self.factory.register_model("mock_model", MagicMock(spec=Model))
|
|
93
|
+
model = self.factory.create_model(
|
|
94
|
+
"mock_model", self.mock_config, loader=MagicMock())
|
|
95
|
+
self.assertIsNotNone(model)
|
|
96
|
+
|
|
97
|
+
with self.assertRaises(ModelError):
|
|
98
|
+
self.factory.create_model(
|
|
99
|
+
"unknown_model", self.mock_config, loader=MagicMock())
|
|
100
|
+
|
|
101
|
+
def test_create_metric(self):
|
|
102
|
+
self.mock_config = ConfigFactory.from_args(self.config_data)
|
|
103
|
+
metric = self.factory.create_metric("r2", self.mock_config)
|
|
104
|
+
self.assertIsNotNone(metric)
|
|
105
|
+
|
|
106
|
+
with self.assertRaises(MetricError):
|
|
107
|
+
self.factory.create_metric("unknown_metric", self.mock_config)
|
|
108
|
+
|
|
109
|
+
def test_create_predictor(self):
|
|
110
|
+
predictor = self.factory.create_predictor("default")
|
|
111
|
+
self.assertIsNotNone(predictor)
|
|
112
|
+
|
|
113
|
+
with self.assertRaises(KeyError):
|
|
114
|
+
self.factory.create_predictor("unknown_predictor")
|
|
115
|
+
|
|
116
|
+
def test_create_valuator(self):
|
|
117
|
+
valuator = self.factory.create_valuator(
|
|
118
|
+
"model", self.mock_model, device="cpu")
|
|
119
|
+
self.assertIsNotNone(valuator)
|
|
120
|
+
|
|
121
|
+
with self.assertRaises(KeyError):
|
|
122
|
+
self.factory.create_valuator(
|
|
123
|
+
"unknown_valuator", self.mock_model, device="cpu")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if __name__ == "__main__":
|
|
127
|
+
unittest.main()
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|