atdata 0.1.1a3__py3-none-any.whl → 0.1.2a3__py3-none-any.whl
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.
- atdata/__init__.py +1 -0
- atdata/dataset.py +48 -3
- {atdata-0.1.1a3.dist-info → atdata-0.1.2a3.dist-info}/METADATA +1 -1
- atdata-0.1.2a3.dist-info/RECORD +8 -0
- atdata-0.1.1a3.dist-info/RECORD +0 -8
- {atdata-0.1.1a3.dist-info → atdata-0.1.2a3.dist-info}/WHEEL +0 -0
- {atdata-0.1.1a3.dist-info → atdata-0.1.2a3.dist-info}/entry_points.txt +0 -0
- {atdata-0.1.1a3.dist-info → atdata-0.1.2a3.dist-info}/licenses/LICENSE +0 -0
atdata/__init__.py
CHANGED
atdata/dataset.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import webdataset as wds
|
|
7
7
|
|
|
8
|
+
import functools
|
|
8
9
|
from dataclasses import dataclass
|
|
9
10
|
import uuid
|
|
10
11
|
|
|
@@ -96,7 +97,8 @@ def _make_packable( x ):
|
|
|
96
97
|
class PackableSample( ABC ):
|
|
97
98
|
"""A sample that can be packed and unpacked with msgpack"""
|
|
98
99
|
|
|
99
|
-
def
|
|
100
|
+
def _ensure_good( self ):
|
|
101
|
+
"""TODO Stupid kludge because of __post_init__ nonsense for wrapped classes"""
|
|
100
102
|
|
|
101
103
|
# Auto-convert known types when annotated
|
|
102
104
|
for var_name, var_type in vars( self.__class__ )['__annotations__'].items():
|
|
@@ -120,12 +122,17 @@ class PackableSample( ABC ):
|
|
|
120
122
|
elif isinstance( var_cur_value, bytes ):
|
|
121
123
|
setattr( self, var_name, eh.bytes_to_array( var_cur_value ) )
|
|
122
124
|
|
|
125
|
+
def __post_init__( self ):
|
|
126
|
+
self._ensure_good()
|
|
127
|
+
|
|
123
128
|
##
|
|
124
129
|
|
|
125
130
|
@classmethod
|
|
126
131
|
def from_data( cls, data: MsgpackRawSample ) -> Self:
|
|
127
132
|
"""Create a sample instance from unpacked msgpack data"""
|
|
128
|
-
|
|
133
|
+
ret = cls( **data )
|
|
134
|
+
ret._ensure_good()
|
|
135
|
+
return ret
|
|
129
136
|
|
|
130
137
|
@classmethod
|
|
131
138
|
def from_bytes( cls, bs: bytes ) -> Self:
|
|
@@ -415,4 +422,42 @@ class Dataset( Generic[ST] ):
|
|
|
415
422
|
# This default implementation simply creates a list one sample at a time
|
|
416
423
|
# """
|
|
417
424
|
# assert cls.batch_class is not None, 'No batch class specified'
|
|
418
|
-
# return cls.batch_class( **batch )
|
|
425
|
+
# return cls.batch_class( **batch )
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
##
|
|
429
|
+
# Shortcut decorators
|
|
430
|
+
|
|
431
|
+
# def packable( cls ):
|
|
432
|
+
# """TODO"""
|
|
433
|
+
|
|
434
|
+
# def decorator( cls ):
|
|
435
|
+
# # Create a new class dynamically
|
|
436
|
+
# # The new class inherits from the new_parent_class first, then the original cls
|
|
437
|
+
# new_bases = (PackableSample,) + cls.__bases__
|
|
438
|
+
# new_cls = type(cls.__name__, new_bases, dict(cls.__dict__))
|
|
439
|
+
|
|
440
|
+
# # Optionally, update __module__ and __qualname__ for better introspection
|
|
441
|
+
# new_cls.__module__ = cls.__module__
|
|
442
|
+
# new_cls.__qualname__ = cls.__qualname__
|
|
443
|
+
|
|
444
|
+
# return new_cls
|
|
445
|
+
# return decorator
|
|
446
|
+
|
|
447
|
+
def packable( cls ):
|
|
448
|
+
"""TODO"""
|
|
449
|
+
|
|
450
|
+
##
|
|
451
|
+
|
|
452
|
+
as_dataclass = dataclass( cls )
|
|
453
|
+
|
|
454
|
+
class as_packable( PackableSample, as_dataclass ):
|
|
455
|
+
def __post_init__( self ):
|
|
456
|
+
return PackableSample.__post_init__( self )
|
|
457
|
+
|
|
458
|
+
as_packable.__name__ = cls.__name__
|
|
459
|
+
as_packable.__annotations__ = cls.__annotations__
|
|
460
|
+
|
|
461
|
+
##
|
|
462
|
+
|
|
463
|
+
return as_packable
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
atdata/__init__.py,sha256=jPZVd_6UIo0DSbCnXAnYZ2eMwHYzOk--5vtEDTZvwqw,173
|
|
2
|
+
atdata/_helpers.py,sha256=R63JhXewAKZYnZ9Th7R6yZh0IOUPYGBsth3FpRUMD-U,503
|
|
3
|
+
atdata/dataset.py,sha256=HXctGwIbU5kr2pqiQCYDyGP1mkph1gIt-x1_PRtWyew,13372
|
|
4
|
+
atdata-0.1.2a3.dist-info/METADATA,sha256=Jj5vP4NW-HtckIsPRzzpXVQXgcQ8HaFSGehdAu4Vfbo,434
|
|
5
|
+
atdata-0.1.2a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
atdata-0.1.2a3.dist-info/entry_points.txt,sha256=6-iQr1veSTq-ac94bLyfcyGHprrZWevPEd12BWX37tQ,39
|
|
7
|
+
atdata-0.1.2a3.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
|
|
8
|
+
atdata-0.1.2a3.dist-info/RECORD,,
|
atdata-0.1.1a3.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
atdata/__init__.py,sha256=VwlLoJkqsXf1XWSzsGGIiuxUluIihR2vHOtYao3w0EY,159
|
|
2
|
-
atdata/_helpers.py,sha256=R63JhXewAKZYnZ9Th7R6yZh0IOUPYGBsth3FpRUMD-U,503
|
|
3
|
-
atdata/dataset.py,sha256=tuph87zUZmSLPIXrHvPxSxdrAknLT_4gKAB4kHTqiZ8,12210
|
|
4
|
-
atdata-0.1.1a3.dist-info/METADATA,sha256=gKjbubI4HoLafCG5p4lsE-1_QMPMaHWZ48TLcIiWKO8,434
|
|
5
|
-
atdata-0.1.1a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
-
atdata-0.1.1a3.dist-info/entry_points.txt,sha256=6-iQr1veSTq-ac94bLyfcyGHprrZWevPEd12BWX37tQ,39
|
|
7
|
-
atdata-0.1.1a3.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
|
|
8
|
-
atdata-0.1.1a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|