Skip to content
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
rev: v1.11.2
hooks:
- id: mypy
args: ["--config=pyproject.toml"]
args: ["--config=pyproject.toml", "--python-version", "3.12"]
additional_dependencies:
- types-requests
- types-aiofiles
Expand Down
30 changes: 21 additions & 9 deletions labellerr/core/datasets/video_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def fetch_files(self, page_size: int = 1000):

# print(params)

response = self.client.make_request(url, params, unique_id)
# Fixed: Pass method as first arg, url as second, params as kwarg

# pprint.pprint(response)
response = self.client.make_request(
method="GET", url=url, request_id=unique_id, params=params
)
# from pprint import pprint
# pprint(response)

# Extract files from the response
files = response.get("response", {}).get("files", [])
Expand All @@ -63,12 +67,15 @@ def fetch_files(self, page_size: int = 1000):
if not next_search_after or not files:
break

print(f"Fetched total: {len(all_file_ids)}")

print(f"Total file IDs extracted: {len(all_file_ids)}")
# return all_file_ids
return all_file_ids

except Exception as e:
raise LabellerrError(f"Failed to fetch dataset files: {str(e)}")

# Create LabellerrVideoFile instances for each file_id
def _create_labellerrfile_instances(self, all_file_ids: list, project_id: str):
# Create LabellerrVideoFile instances for each file_id
try:
video_files = []
print(
f"\nCreating LabellerrFile instances for {len(all_file_ids)} files..."
Expand All @@ -79,7 +86,7 @@ def fetch_files(self, page_size: int = 1000):
video_file = LabellerrFile(
client=self.client,
file_id=file_id,
project_id="self.project_id", # noqa: # todo: ximi we don't have project id here
project_id=project_id, # noqa: # todo: ximi we don't have project id here
dataset_id=self.dataset_id,
)
video_files.append(video_file)
Expand All @@ -94,7 +101,7 @@ def fetch_files(self, page_size: int = 1000):
except Exception as e:
raise LabellerrError(f"Failed to fetch dataset files: {str(e)}")

def download(self):
def download(self, project_id: str):
"""
Process all video files in the dataset: download frames, create videos,
and automatically clean up temporary files.
Expand All @@ -107,8 +114,13 @@ def download(self):
print(f"# Starting batch video processing for dataset: {self.dataset_id}")
print(f"{'#'*70}\n")

# Fetch all files ids
all_files_ids = self.fetch_files()

# Fetch all video files
video_files = self.fetch_files()
video_files = self._create_labellerrfile_instances(
all_files_ids, project_id
)

if not video_files:
print("No video files found in dataset")
Expand Down
7 changes: 5 additions & 2 deletions labellerr/core/files/video_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def get_frames(self, frame_start: int = 0, frame_end: int | None = None):
"frame_end": frame_end,
"project_id": self.project_id,
"uuid": unique_id,
"client_id": self.client.client_id,
}

response = self.client.make_request(url, params, unique_id)
response = self.client.make_request(
"GET", url, request_id=unique_id, params=params
)

return response

Expand Down Expand Up @@ -233,7 +236,7 @@ def create_video(
raise LabellerrError(f"Error while joining frames: {str(e)}")

def download_create_video_auto_cleanup(
self, output_folder: str = "./Labellerr_datastets"
self, output_folder: str = "./Labellerr_datasets"
):
"""
Download frames, create video, and automatically clean up temporary frames.
Expand Down
Loading