@@ -85,7 +85,7 @@ Use ``get_path(key)`` to build a relative path from a typed key.
8585 rel_frame = schema.frames.get_path(fkey) # Path('labeled-data/frames/sessionA/frame_00000042.png')
8686
8787 Parsing the path for a resource: path → keys
88- ---------------------------
88+ ------------------------------------------------------
8989Use ``parse_path(rel_path) `` to parse a relative path back into a key.
9090
9191.. code-block :: python
@@ -100,7 +100,7 @@ Use ``parse_path(rel_path)`` to parse a relative path back into a key.
100100 does not match the resource pattern.
101101
102102Listing out resources (enumeration)
103- -----------------------------------
103+ ----------------------------------------------------------------------------
104104The following methods list out resources currently present in the project directory.
105105
106106- ``iter_paths() `` → yields ``Path `` objects relative to ``schema.base_dir ``
@@ -111,7 +111,7 @@ Example: listing out video files
111111
112112.. code-block :: pycon
113113
114- >>> video_keys = schema.videos .list_keys()
114+ >>> video_keys = schema.VIDEO.list_keys() .list_keys()
115115
116116 >>> for v_key in video_keys:
117117 ... print(v_key.session_key, v_key.view)
@@ -122,12 +122,13 @@ Example: listing out video files
122122 05272019_fly1_0_R3C1_str-cw-0_sec, Cam-B
123123 ...
124124
125+
125126 Example: listing out label files and their paths
126127
127128.. code-block :: pycon
128129
129130 >>> key_and_path = [
130- ... (schema.label_files .parse_path(p), p)
131+ ... (schema.LABEL_FILE .parse_path(p), p)
131132 ... for p in schema.label_files.iter_paths()
132133 ... ]
133134 >>> for (labelfilekey, view), path in key_and_path:
@@ -141,93 +142,17 @@ Example: listing out label files and their paths
141142 ...
142143
143144
144- Strictness during enumeration
145- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146- By default, enumeration is strict and will raise a ``PathParseException `` if a
147- non-matching file is encountered. To bypass strict behavior and skip
148- non-matching files, pass ``strict=False ``.
149-
150- .. code-block :: python
151-
152- # skip files that do not match the expected pattern
153- keys = list (schema.videos.iter_keys(strict = False ))
154-
155-
156- Single-view vs multiview
157- ========================
158- In multiview projects, view-specific placeholders appear in templates and keys.
159-
160- .. code-block :: python
161-
162- from lightning_pose.data.keys import VideoFileKey
163-
164- mv_schema = ProjectSchema.for_version(1 , is_multiview = True , base_dir = schema.base_dir)
165-
166- vA = VideoFileKey(session_key = " S1" , view = " camA" )
167- vB = VideoFileKey(session_key = " S1" , view = " camB" )
168-
169- pA = mv_schema.videos.get_path(vA) # Path('videos/S1_camA.mp4')
170- pB = mv_schema.videos.get_path(vB) # Path('videos/S1_camB.mp4')
171-
172- kA = mv_schema.videos.parse_path(" videos/S1_camA.mp4" )
173- assert kA == vA
174-
175- Recipes
176- =======
177- List all videos and their label files
178- -------------------------------------
179-
180- .. code-block :: python
181-
182- from lightning_pose.utils.paths import ResourceType
183-
184- videos = schema.videos.list_keys() # list[VideoFileKey]
185- labels = [
186- (schema.label_files.parse_path(p.relative_to(schema.base_dir)), p)
187- for p in schema.label_files.iter_paths()
188- ] # list[((LabelFileKey, View|None), Path)]
189-
190- # Create a map from video session to label file path(s)
191- from collections import defaultdict
192- by_session = defaultdict(list )
193- for (label_key, path) in labels:
194- lfile_key, view = label_key # unpack tuple
195- by_session[lfile_key].append(path)
196-
197- # Use resource map generically
198- frames_util = schema.for_(ResourceType.frames)
199- frame_keys = frames_util.list_keys() # list[FrameKey]
200-
201- Find all frames for a specific session
202- --------------------------------------
203-
204- .. code-block :: python
205-
206- # Filter in memory after enumeration
207- all_frames = schema.frames.list_keys()
208- s1_frames = [fk for fk in all_frames if fk.session_key == " sessionA" ]
209-
210- Validate key ↔ path round-trip
211- ------------------------------
212-
213- .. code-block :: python
214-
215- fk = FrameKey(session_key = " S2" , view = None , frame_index = 123 )
216- path = schema.frames.get_path(fk)
217- assert schema.frames.parse_path(path) == fk
218-
219-
220145 API reference
221146=============
222147
223- .. autoclass :: lightning_pose.utils.paths.project_schema_v1.ProjectSchemaV1
224- :special-members: __init__
225- :inherited-members:
148+ .. autoclass :: lightning_pose.utils.paths.project_schema.ProjectSchema
226149 :members:
227150 :member-order: bysource
228151 :undoc-members:
152+ :exclude-members: for _,__init__
153+
229154
230- .. autoclass :: lightning_pose.utils.paths.AbstractResourceUtil
155+ .. autoclass :: lightning_pose.utils.paths.ResourceUtil
231156 :inherited-members:
232157 :members:
233158 :member-order: bysource
0 commit comments