|
6 | 6 | import os |
7 | 7 | import uuid |
8 | 8 | import zipfile |
9 | | -from typing import Optional, List, Any, Dict, Union, Tuple |
| 9 | +from typing import Optional, List, Any, Dict, Union, Tuple, Literal |
10 | 10 |
|
11 | 11 | import aiohttp |
12 | 12 | import requests |
|
20 | 20 | RetryError, |
21 | 21 | ) |
22 | 22 |
|
| 23 | +from dashscope.finetune.reinforcement import logger |
| 24 | +from dashscope.finetune.reinforcement.common.errors import ( |
| 25 | + InputError, OutputError, BaseConnectionError, ConfigurationError, BasePermissionError, RuntimeErrorWithCode, OSSUploadError |
| 26 | +) |
| 27 | +from dashscope.finetune.reinforcement import (LOG_LEVEL, DASHSCOPE_HTTP_BASE_URL, |
| 28 | + DASHSCOPE_API_KEY, BAILIAN_FILE_API, |
| 29 | + BAILIAN_FILE_TIMEOUT, HTTP_REQUEST_TIMEOUT, |
| 30 | + FC_API_KEY, FC_FILES_START, FC_PYPI_LIB, FC_PYPI_REPO, FC_LAYER_USED, |
| 31 | + FC_SERVER_CLASSPATH, FC_ZIP_EXCLUDE_PATTERNS, FC_OSS_FILE_SIZE_WARNING, |
| 32 | + LOGGER_FILTER_FIELDS, FC_WORKERS_COUNT) |
| 33 | +from dashscope.finetune.reinforcement.common.model_types import FileSpec, FunctionType |
| 34 | + |
23 | 35 |
|
24 | 36 | def generate_random_id(prefix: str = "") -> str: |
25 | 37 | """Generate a unique identifier with optional prefix.""" |
@@ -436,7 +448,10 @@ def _should_exclude(path: str, patterns: List[str]) -> Optional[str]: |
436 | 448 | matched = _should_exclude( |
437 | 449 | normalized_path, all_excludes |
438 | 450 | ) |
439 | | - if matched: |
| 451 | + |
| 452 | + if not matched: |
| 453 | + the_dirs.append(d) |
| 454 | + else: |
440 | 455 | logger.debug( |
441 | 456 | f"Excluding directory: {normalized_path} (matched pattern: '{matched}')" |
442 | 457 | ) |
@@ -499,7 +514,7 @@ def _sync_upload_to_oss(signed_url: str, zip_path: str) -> int: |
499 | 514 | f"Uploading file: {zip_path} ({size_mb:.2f}MB) to OSS" |
500 | 515 | ) |
501 | 516 |
|
502 | | - with open(zip_path, "rb", encoding="utf-8") as file: |
| 517 | + with open(zip_path, "rb") as file: |
503 | 518 | response = requests.put( |
504 | 519 | signed_url, data=file, headers={}, timeout=BAILIAN_FILE_TIMEOUT |
505 | 520 | ) |
@@ -578,7 +593,7 @@ async def to_bailian_data(files: List[FileSpec]) -> List[str]: |
578 | 593 | continue |
579 | 594 |
|
580 | 595 | # Add file to form data |
581 | | - with open(file_path, "rb", encoding="utf-8") as f: |
| 596 | + with open(file_path, "rb") as f: |
582 | 597 | form_data.add_field( |
583 | 598 | name="files", |
584 | 599 | value=f.read(), |
|
0 commit comments