-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Increase file size limit from 25GB to 50.1GB #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6b685e2
3c5264f
18163e0
c11bb5a
7ac3d44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,6 +212,7 @@ def download( | |
| ), | ||
| remaining_retries=MAX_RETRIES, | ||
| stream=True, | ||
| request_timeout=3600, | ||
| ) | ||
|
|
||
| try: | ||
|
|
@@ -522,29 +523,47 @@ def _upload_parts_concurrent( | |
|
|
||
| with ThreadPoolExecutor(max_workers=self.max_concurrent_parts) as executor: | ||
| with tqdm(total=len(parts), desc="Uploading parts", unit="part") as pbar: | ||
| future_to_part = {} | ||
|
|
||
| with open(file, "rb") as f: | ||
| for part_info in parts: | ||
| future_to_part = {} | ||
| part_index = 0 | ||
|
|
||
| # Submit initial batch limited by max_concurrent_parts | ||
| for i in range(min(self.max_concurrent_parts, len(parts))): | ||
| part_info = parts[part_index] | ||
| f.seek((part_info["PartNumber"] - 1) * part_size) | ||
| part_data = f.read(part_size) | ||
|
|
||
| future = executor.submit( | ||
| self._upload_single_part, part_info, part_data | ||
| ) | ||
| future_to_part[future] = part_info["PartNumber"] | ||
|
|
||
| # Collect results | ||
| for future in as_completed(future_to_part): | ||
| part_number = future_to_part[future] | ||
| try: | ||
| etag = future.result() | ||
| completed_parts.append( | ||
| {"part_number": part_number, "etag": etag} | ||
| ) | ||
| pbar.update(1) | ||
| except Exception as e: | ||
| raise Exception(f"Failed to upload part {part_number}: {e}") | ||
| part_index += 1 | ||
|
|
||
| # Process completions and submit new parts (sliding window) | ||
| while future_to_part: | ||
| done_future = next(as_completed(future_to_part)) | ||
| part_number = future_to_part.pop(done_future) | ||
|
|
||
| try: | ||
| etag = done_future.result() | ||
| completed_parts.append( | ||
| {"part_number": part_number, "etag": etag} | ||
| ) | ||
| pbar.update(1) | ||
| except Exception as e: | ||
| raise Exception(f"Failed to upload part {part_number}: {e}") | ||
|
|
||
| # Submit next part if available | ||
| if part_index < len(parts): | ||
| part_info = parts[part_index] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be great to rewrite it to deduplicate this code piece with the one above. I think you can either make a for loop to submit tasks and wait on result if we have enough already, or use executor.map with buffersize to limit concurrent tasks. |
||
| f.seek((part_info["PartNumber"] - 1) * part_size) | ||
| part_data = f.read(part_size) | ||
|
|
||
| future = executor.submit( | ||
| self._upload_single_part, part_info, part_data | ||
| ) | ||
| future_to_part[future] = part_info["PartNumber"] | ||
| part_index += 1 | ||
|
|
||
| completed_parts.sort(key=lambda x: x["part_number"]) | ||
| return completed_parts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| from traceback import format_exc | ||
| from typing import Any, Dict, List | ||
|
|
||
| from tqdm import tqdm | ||
|
|
||
| from together.constants import ( | ||
| MAX_FILE_SIZE_GB, | ||
|
|
@@ -363,14 +364,19 @@ def _check_utf8(file: Path) -> Dict[str, Any]: | |
| Dict[str, Any]: A dictionary with the results of the check. | ||
| """ | ||
| report_dict: Dict[str, Any] = {} | ||
|
|
||
| try: | ||
| chunk_size = 8192 | ||
| with file.open(encoding="utf-8") as f: | ||
| f.read() | ||
| for chunk in iter(lambda: f.read(chunk_size), ""): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think just do |
||
| pass | ||
|
|
||
| report_dict["utf8"] = True | ||
| except UnicodeDecodeError as e: | ||
| report_dict["utf8"] = False | ||
| report_dict["message"] = f"File is not UTF-8 encoded. Error raised: {e}." | ||
| report_dict["is_check_passed"] = False | ||
|
|
||
| return report_dict | ||
|
|
||
|
|
||
|
|
@@ -470,7 +476,7 @@ def _check_jsonl(file: Path, purpose: FilePurpose | str) -> Dict[str, Any]: | |
| with file.open() as f: | ||
| idx = -1 | ||
| try: | ||
| for idx, line in enumerate(f): | ||
| for idx, line in tqdm(enumerate(f), desc="Validating file", unit=" lines"): | ||
| json_line = json.loads(line) | ||
|
|
||
| if not isinstance(json_line, dict): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you dropped "S3 limit" mention, is it still the case?