ialdev-dataman 0.1.0__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.
Files changed (86) hide show
  1. ialdev_dataman-0.1.0/PKG-INFO +33 -0
  2. ialdev_dataman-0.1.0/README.md +5 -0
  3. ialdev_dataman-0.1.0/docs/use_cases.md +110 -0
  4. ialdev_dataman-0.1.0/docs/use_cases.py +134 -0
  5. ialdev_dataman-0.1.0/pyproject.toml +53 -0
  6. ialdev_dataman-0.1.0/src/iad/dataman/__init__.py +22 -0
  7. ialdev_dataman-0.1.0/src/iad/dataman/datacast/__init__.py +8 -0
  8. ialdev_dataman-0.1.0/src/iad/dataman/datacast/caster.py +523 -0
  9. ialdev_dataman-0.1.0/src/iad/dataman/datacast/collect.py +1466 -0
  10. ialdev_dataman-0.1.0/src/iad/dataman/datacast/labeled.py +80 -0
  11. ialdev_dataman-0.1.0/src/iad/dataman/datacast/scan.py +178 -0
  12. ialdev_dataman-0.1.0/src/iad/dataman/datacast/transforms.py +40 -0
  13. ialdev_dataman-0.1.0/src/iad/dataman/datacast/transtools.py +608 -0
  14. ialdev_dataman-0.1.0/src/iad/dataman/env.py +10 -0
  15. ialdev_dataman-0.1.0/src/iad/dataman/factories.py +143 -0
  16. ialdev_dataman-0.1.0/src/iad/dataman/models.py +425 -0
  17. ialdev_dataman-0.1.0/src/iad/dataman/resman.py +1229 -0
  18. ialdev_dataman-0.1.0/tests/conftest.py +28 -0
  19. ialdev_dataman-0.1.0/tests/datacast/data/datasets/toy/datasource.yml +5 -0
  20. ialdev_dataman-0.1.0/tests/datacast/data/datasource.yml +3 -0
  21. ialdev_dataman-0.1.0/tests/datacast/data/res/FT3D.col.yml +5 -0
  22. ialdev_dataman-0.1.0/tests/datacast/data/res/FT3D.ds.yml +3 -0
  23. ialdev_dataman-0.1.0/tests/datacast/data/res/FT3D.scm.yml +26 -0
  24. ialdev_dataman-0.1.0/tests/datacast/data/res/source_1.src.yml +0 -0
  25. ialdev_dataman-0.1.0/tests/datacast/data/res/source_2.src.yml +0 -0
  26. ialdev_dataman-0.1.0/tests/datacast/data/res/test_FT3D.src.yml +6 -0
  27. ialdev_dataman-0.1.0/tests/datacast/data/res/toy_split.ds.yml +14 -0
  28. ialdev_dataman-0.1.0/tests/datacast/data/scheme.yml +5 -0
  29. ialdev_dataman-0.1.0/tests/datacast/test_collect.py +127 -0
  30. ialdev_dataman-0.1.0/tests/datacast/test_scheme.py +191 -0
  31. ialdev_dataman-0.1.0/tests/datasets/data/datasets/toy/datasource.yml +5 -0
  32. ialdev_dataman-0.1.0/tests/datasets/data/datasource.yml +3 -0
  33. ialdev_dataman-0.1.0/tests/datasets/data/res/FT3D.col.yml +5 -0
  34. ialdev_dataman-0.1.0/tests/datasets/data/res/FT3D.ds.yml +3 -0
  35. ialdev_dataman-0.1.0/tests/datasets/data/res/FT3D.scm.yml +26 -0
  36. ialdev_dataman-0.1.0/tests/datasets/data/res/source_1.src.yml +0 -0
  37. ialdev_dataman-0.1.0/tests/datasets/data/res/source_2.src.yml +0 -0
  38. ialdev_dataman-0.1.0/tests/datasets/data/res/test_FT3D.src.yml +6 -0
  39. ialdev_dataman-0.1.0/tests/datasets/data/res/toy_split.ds.yml +14 -0
  40. ialdev_dataman-0.1.0/tests/datasets/data/scheme.yml +5 -0
  41. ialdev_dataman-0.1.0/tests/datasets/test_datasets.py +30 -0
  42. ialdev_dataman-0.1.0/tests/datasets/test_models.py +155 -0
  43. ialdev_dataman-0.1.0/tests/resman/data/res/nested/wind.dply.yml +3 -0
  44. ialdev_dataman-0.1.0/tests/resman/data/res/nested/windtwo.dply.yml +3 -0
  45. ialdev_dataman-0.1.0/tests/resman/data/res/wind.dply.yml +3 -0
  46. ialdev_dataman-0.1.0/tests/resman/test_resource.py +35 -0
  47. ialdev_dataman-0.1.0/tests/test.env +7 -0
  48. ialdev_dataman-0.1.0/tests/test_resources/data/StereoImage_1058262900228717.tif +0 -0
  49. ialdev_dataman-0.1.0/tests/test_resources/data/bench/tiny/metrics_94362.hdf +0 -0
  50. ialdev_dataman-0.1.0/tests/test_resources/data/evals/tiny/Adirondack##1#1#1/conf#NU40#0.0#6de6#L.tif +0 -0
  51. ialdev_dataman-0.1.0/tests/test_resources/data/evals/tiny/Adirondack##1#1#1/disp#NU40#0.0#6de6#L.tif +0 -0
  52. ialdev_dataman-0.1.0/tests/test_resources/data/evals/tiny/Piano##1#1#1/conf#NU40#0.0#6de6#L.tif +0 -0
  53. ialdev_dataman-0.1.0/tests/test_resources/data/evals/tiny/Piano##1#1#1/disp#NU40#0.0#6de6#L.tif +0 -0
  54. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/calib.txt +12 -0
  55. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/disp0GT.tif +0 -0
  56. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/disp1GT.tif +0 -0
  57. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/im0.jpg +0 -0
  58. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/im0_gray.jpg +0 -0
  59. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/im1.jpg +0 -0
  60. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/im1_gray.jpg +0 -0
  61. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/mask0nocc.jpg +0 -0
  62. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Adirondack/mask1nocc.jpg +0 -0
  63. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/calib.txt +12 -0
  64. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/disp0GT.tif +0 -0
  65. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/disp1GT.tif +0 -0
  66. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/im0.jpg +0 -0
  67. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/im0_gray.jpg +0 -0
  68. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/im1.jpg +0 -0
  69. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/im1_gray.jpg +0 -0
  70. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/mask0nocc.jpg +0 -0
  71. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/Piano/mask1nocc.jpg +0 -0
  72. ialdev_dataman-0.1.0/tests/test_resources/data/tiny_stereo/datasource.yml +5 -0
  73. ialdev_dataman-0.1.0/tests/test_resources/resources/benchmarks/tiny.bmk.yml +68 -0
  74. ialdev_dataman-0.1.0/tests/test_resources/resources/collections/tiny.col.yml +5 -0
  75. ialdev_dataman-0.1.0/tests/test_resources/resources/collections/tiny_2.col.yml +5 -0
  76. ialdev_dataman-0.1.0/tests/test_resources/resources/datasets/tiny.ds.yml +3 -0
  77. ialdev_dataman-0.1.0/tests/test_resources/resources/issues/categorical/issue.xlsx +0 -0
  78. ialdev_dataman-0.1.0/tests/test_resources/resources/issues/selector_issues.csv +14 -0
  79. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/depth/Monkaa_output_from_NU.scm.yml +21 -0
  80. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/depth/labels.yml +47 -0
  81. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/depth/repos/bench_evals.scm.yml +5 -0
  82. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/depth/repos/bench_results.scm.yml +2 -0
  83. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/labels.yml +47 -0
  84. ialdev_dataman-0.1.0/tests/test_resources/resources/schemes/tiny.scm.yml +33 -0
  85. ialdev_dataman-0.1.0/tests/test_resources/resources/trainings/test_training_config.trn.yml +61 -0
  86. ialdev_dataman-0.1.0/tests/test_resources/resources/trainings/test_training_curriculum_config.trn.yml +94 -0
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: ialdev-dataman
3
+ Version: 0.1.0
4
+ Summary: iad.dataman — data casting, resource models, and dataset bridge
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Dist: ialdev-core
15
+ Requires-Dist: ialdev-io
16
+ Requires-Dist: ialdev-img
17
+ Requires-Dist: ialdev-maths
18
+ Requires-Dist: pandas>=1.3.0
19
+ Requires-Dist: numpy>=1.20.0
20
+ Requires-Dist: pydantic>=2.0
21
+ Requires-Dist: pyyaml>=5.4.0
22
+ Requires-Dist: regex>=2021.0.0
23
+ Requires-Dist: tqdm>=4.60.0
24
+ Requires-Dist: pytest>=7.0.0 ; extra == "dev"
25
+ Requires-Dist: pytest-cov>=3.0.0 ; extra == "dev"
26
+ Provides-Extra: dev
27
+
28
+ # ialdev-dataman
29
+
30
+ `iad.dataman` — data casting, resource models, and dataset bridge.
31
+
32
+ Install: `pip install ialdev-dataman`
33
+
@@ -0,0 +1,5 @@
1
+ # ialdev-dataman
2
+
3
+ `iad.dataman` — data casting, resource models, and dataset bridge.
4
+
5
+ Install: `pip install ialdev-dataman`
@@ -0,0 +1,110 @@
1
+ # Resource Management - Use Cases
2
+
3
+ First make sure you are familiar with the main [concepts](./concepts.md).
4
+
5
+ # Resources Life Timeline
6
+
7
+ ### Resource Type Definition
8
+ Every resource is an instance of certain _resource type_ which must be defined first.
9
+
10
+ Resource types implemented as subclasses of pydantic model ``ResourseModel``
11
+ (thus may be called resource models).
12
+
13
+ ```python
14
+ from iad.dataman.resman import ResourceModel, locatable
15
+ from iad.core.env import EnvLoc
16
+
17
+
18
+ @locatable(EnvLoc.RESOURCES / 'houses')
19
+ class HouseModel(ResourceModel):
20
+ rooms: int
21
+ area: float
22
+ ...
23
+
24
+ ```
25
+ There are two stages in introducing resources into the framework:
26
+
27
+ 1. Define a *locatable* Resource Model
28
+ 2. Discover resources in the defined locations
29
+
30
+ ### Creation
31
+ Resources can be created:
32
+ 1. explicitly as `*.yml` _files_
33
+ 2. explicitly as _instances_ of the corresponding `pydantic` model class
34
+ 3. implicitly during initialization of other resource as default attributes
35
+
36
+ ### Discovery of Filed Resources
37
+ To be accessibly through the `resman` API the file-form resources must
38
+ be first _discovered_ and initialized as _instances_.
39
+
40
+ Discovery of resources is responsibility resource managers of their particular type. \
41
+ Those managers are created automatically _when a new class of resource Model is imported_.
42
+ ``ModelsManager`` class can be used as a single access point to the resource management system.
43
+
44
+ For example, lets assume there is
45
+
46
+ ```python
47
+ from inu.resman import ModelsManager # initialize the resource management sub-system
48
+
49
+ # At this stage no specific resource types are registered in the ModelsManager!
50
+
51
+ assert not ModelsManager.list()
52
+ # Let's import model of datasets management resources defined by the ``datacast`` package.
53
+ from inu.datacast import models as dm
54
+
55
+ # Now all the resource Models (Datasource, Scheme, Dataset, DataCollection)
56
+ # from there are registered in the ModelManager
57
+ assert ModelsManager.list() > 3
58
+
59
+ # Manger of specific resource type can be found by its model class or name
60
+ ds_man = ModelsManager.get(dm.DatasetRM)
61
+ assert ds_man is ModelsManager.get('dataset')
62
+
63
+ # Discovery of its resources are can be requested
64
+ ds_man.discover() # without arguments look in the default locations
65
+
66
+ # There is a shortcut version of this sequence:
67
+ ModelsManager.discover('dataset')
68
+
69
+ # Or, to discover resources from all the currently registered models
70
+ ModelsManager.discover()
71
+ ```
72
+
73
+
74
+ ## Scenarios
75
+
76
+ ### Initialization
77
+
78
+ #### Access Resource Models
79
+
80
+ ```python
81
+ from inu.datacast import ModelsManager, ResManager, find_resource
82
+
83
+ dsm: ResManager = ModelsManager.find("dataset")
84
+ assert dsm is None, "DatasetRM is not been imported yet"
85
+
86
+ from inu.datacast import models
87
+ # that imports among the other DatasetRM
88
+ dsm = find_resource('dataset')
89
+ assert isinstance(dsm, ResManager)
90
+ ```
91
+
92
+ #### Scan Resource Folders
93
+
94
+ ```python
95
+ from inu.datacast.models import DatasetRM
96
+ from inu.resman import ModelsManager
97
+
98
+ dsm = ModelsManager.find(DatasetRM)
99
+ assert dsm.list().empty, "Never scanned"
100
+ assert dsm.folders(), "Some Folders are defined with Model"
101
+ assert any(p.is_dir() for p in dsm.folders()), "Some folders must exist"
102
+
103
+ dsm.discover() # assuming there are resources there
104
+ assert not dsm.list().empty
105
+
106
+
107
+
108
+ ```
109
+
110
+
@@ -0,0 +1,134 @@
1
+ from __future__ import annotations
2
+ # FixMe: Do we still need that?
3
+
4
+ from typing import Optional
5
+
6
+ from iad.dataman.env import EnvLoc
7
+ from iad.dataman.resman import ModelsManager, ResourceModel # initialize the resource management sub-system
8
+ from iad.core.logs import setup_logs, logger
9
+
10
+
11
+ mm = ModelsManager()
12
+
13
+
14
+ _log = logger('use_cases')
15
+ lof_func_enable = False
16
+
17
+
18
+ class MyRes(ResourceModel):
19
+ description: str = "Hi"
20
+
21
+
22
+ class MyRes(ResourceModel):
23
+ description: str = "Hi"
24
+
25
+
26
+ def log_func(f):
27
+ def wrapper(*args, **kwargs):
28
+ _log.warning(f"------------------- {f.__name__.upper()} ---------------------")
29
+ return f(*args, **kwargs)
30
+ return wrapper if lof_func_enable else f
31
+
32
+
33
+ def case_create_resource():
34
+ class ResAModel(ResourceModel):
35
+ description: Optional[str]
36
+
37
+ ra1 = ResAModel('a1', description='Wrong')
38
+ assert ra1.description
39
+
40
+
41
+ @log_func
42
+ def case_init_models_management():
43
+ import iad.dataman.models as dm
44
+ # At this stage no specific resource types are registered in the mm!
45
+ mm._reset() # but we reset anyway for robustness of the test
46
+ assert not mm.list()
47
+ # Let's import model of datasets management resources defined by the ``datasets`` bridge.
48
+ mm.register_models(dm)
49
+ # Now all the resource Models (Datasource, Scheme, Dataset, DataCollection)
50
+ # from there are registered in the ModelManager
51
+ assert len(mm.list()) > 3
52
+
53
+ # Manger of specific resource type can be found by its model class or name
54
+ datasets = mm.get(dm.DatasetRM)
55
+ assert datasets is mm.get('dataset') # search by name
56
+
57
+
58
+ @log_func
59
+ def case_resource_creation():
60
+
61
+ from iad.dataman.models import DataSourceRM
62
+ src = DataSourceRM.parse_file(EnvLoc.DATA / 'datasource.yml') # config from yaml file - Standard
63
+
64
+ data_root = EnvLoc.DATA.first_existing()
65
+ # From config dict
66
+ cfg = {'name': 'SourceName', 'root': data_root}
67
+ src = DataSourceRM.parse_obj(cfg) # 1. config from dict - pydantic
68
+ src = DataSourceRM(**cfg) # 2. config from arguments - Standard
69
+
70
+ # Manual registration
71
+ src = DataSourceRM('SourceName', root=data_root) # name positional - Special init!
72
+ assert str(src)
73
+ assert not src.is_listed
74
+ DataSourceRM._manager.add_resource(src)
75
+ assert src.is_listed
76
+ assert src == DataSourceRM('SourceName') # Query config # 4. config from query - Special init!
77
+ assert src == DataSourceRM.from_config('SourceName') # ?? Alternative - Dedicated method for query!
78
+
79
+ src = DataSourceRM(root=data_root) # Optional name - default|special init (need?)
80
+ assert repr(src)
81
+
82
+
83
+ @log_func
84
+ def case_resource_discoveries():
85
+ # Resource Manager may be found also by a part of its name
86
+ sources = mm.get('source')
87
+ assert sources.discover() # some has been registered
88
+
89
+ # Manager contains its associated Resource Model as attribute
90
+ res = sources.list('res')[0]
91
+ assert sources.model(res.name) == res
92
+
93
+ # There is a shortcut version of this sequence:
94
+ assert mm.discover('source') == len(sources)
95
+
96
+ # Or, to discover resources from all the currently registered models
97
+ mm.discover()
98
+
99
+
100
+ @log_func
101
+ def scenario_work_with_collection():
102
+ from iad.dataman import create_collection
103
+ mm.discover()
104
+ dc = create_collection('KITTI',
105
+ query=dict(subset='train'))
106
+
107
+ mm.discover('scheme')
108
+ src = mm.get('source')
109
+ src.discover('/mnt/algo/DataSets/depth', only=False)
110
+ mm.discover('scheme')
111
+
112
+ dc = create_collection('MID14S', temp_cache=True)
113
+ mm.discover('collect')
114
+
115
+
116
+ @log_func
117
+ def case_create_data_caster():
118
+ from iad.dataman import create_caster
119
+ my_dataset = create_caster(source=EnvLoc.DATA / 'my_dataset',
120
+ scheme='{width}_{height}_{color}_{material}.jpg',
121
+ filters=dict(color='BLUE',
122
+ material=['steal', 'wood'],
123
+ width=float(10).__le__,
124
+ condition_square='height == width'))
125
+
126
+
127
+ @log_func
128
+ def scenario_typical_flow():
129
+ from iad.dataman import create_caster, create_collection
130
+ case_resource_discoveries()
131
+ eth3d = create_caster('ETH3D')
132
+ dc = create_collection(datasets=[eth3d])
133
+ dc = create_collection(datasets=['MIDS12', 'FT3D'])
134
+ dc = create_collection('SmallQualityEval')
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["flit_core>=3.11,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "ialdev-dataman"
7
+ version = "0.1.0"
8
+ description = "iad.dataman — data casting, resource models, and dataset bridge"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ ]
21
+
22
+ dependencies = [
23
+ "ialdev-core",
24
+ "ialdev-io",
25
+ "ialdev-img",
26
+ "ialdev-maths",
27
+ "pandas>=1.3.0",
28
+ "numpy>=1.20.0",
29
+ "pydantic>=2.0",
30
+ "pyyaml>=5.4.0",
31
+ "regex>=2021.0.0",
32
+ "tqdm>=4.60.0",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "pytest>=7.0.0",
38
+ "pytest-cov>=3.0.0",
39
+ ]
40
+
41
+ [tool.flit.module]
42
+ name = "iad.dataman"
43
+
44
+ [tool.pytest.ini_options]
45
+ testpaths = ["tests"]
46
+ python_files = ["test_*.py"]
47
+ python_classes = ["Test*"]
48
+ python_functions = ["test_*"]
49
+
50
+ [tool.black]
51
+ line-length = 100
52
+ target-version = ["py310", "py311", "py312"]
53
+ include = '\.pyi?$'
@@ -0,0 +1,22 @@
1
+ """iad.dataman — datacast, resman, and datasets bridge (``ialdev-dataman`` distribution)."""
2
+
3
+ from .models import DataSourceRM, SchemeRM, DatasetRM, CollectionRM, DSample, discover
4
+ from .factories import create_caster, create_collection, create_sink
5
+ from .datacast.collect import DataCollection, SinkRepo
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ __all__ = [
10
+ "__version__",
11
+ "DataSourceRM",
12
+ "SchemeRM",
13
+ "DatasetRM",
14
+ "CollectionRM",
15
+ "DSample",
16
+ "discover",
17
+ "create_caster",
18
+ "create_collection",
19
+ "create_sink",
20
+ "DataCollection",
21
+ "SinkRepo",
22
+ ]
@@ -0,0 +1,8 @@
1
+ """ Data Sets access and management tools."""
2
+
3
+ __all__ = ['DataCaster', 'CasterConfig', 'DataCollection', 'SinkRepo',
4
+ 'Col', 'Fetchable', 'CollectTable', 'CollectSeries']
5
+
6
+ from .transtools import Fetchable, CollectSeries, CollectTable, Col
7
+ from .caster import DataCaster, CasterConfig
8
+ from .collect import DataCollection, SinkRepo