Skip to content

Commit 30c00a1

Browse files
author
zhansheng.lzs
committed
apt: fix some 2
1 parent cbb6cbe commit 30c00a1

12 files changed

Lines changed: 35 additions & 11 deletions

File tree

dashscope/finetune/agentic_rl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def register_functions(
103103
reward_instance_ids,
104104
group_reward_instance_ids,
105105
) = await self.tuning.register_functions(
106-
lazy_load=lazy_load or True,
106+
lazy_load=lazy_load,
107107
)
108108
logger.info("Function components registered")
109109
except Exception as e:

dashscope/finetune/reinforcement/common/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
FunctionType,
2424
)
2525
from dashscope.finetune.reinforcement.common.errors import OutputError
26+
from dashscope.finetune.customize_types import FineTune
27+
2628

2729
app = typer.Typer(
2830
name="agentic-rl",

dashscope/finetune/reinforcement/common/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ class TuningModel(Models, BaseModel):
10381038

10391039
async def register_functions(
10401040
self,
1041-
lazy_load: bool = True,
1041+
lazy_load: Optional[bool] = True,
10421042
) -> tuple[
10431043
List[str], List[str], List[str], List[str], List[str], List[str]
10441044
]:

dashscope/finetune/reinforcement/common/utils.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import uuid
88
import zipfile
9-
from typing import Optional, List, Any, Dict, Union, Tuple
9+
from typing import Optional, List, Any, Dict, Union, Tuple, Literal
1010

1111
import aiohttp
1212
import requests
@@ -20,6 +20,18 @@
2020
RetryError,
2121
)
2222

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+
2335

2436
def generate_random_id(prefix: str = "") -> str:
2537
"""Generate a unique identifier with optional prefix."""
@@ -436,7 +448,10 @@ def _should_exclude(path: str, patterns: List[str]) -> Optional[str]:
436448
matched = _should_exclude(
437449
normalized_path, all_excludes
438450
)
439-
if matched:
451+
452+
if not matched:
453+
the_dirs.append(d)
454+
else:
440455
logger.debug(
441456
f"Excluding directory: {normalized_path} (matched pattern: '{matched}')"
442457
)
@@ -499,7 +514,7 @@ def _sync_upload_to_oss(signed_url: str, zip_path: str) -> int:
499514
f"Uploading file: {zip_path} ({size_mb:.2f}MB) to OSS"
500515
)
501516

502-
with open(zip_path, "rb", encoding="utf-8") as file:
517+
with open(zip_path, "rb") as file:
503518
response = requests.put(
504519
signed_url, data=file, headers={}, timeout=BAILIAN_FILE_TIMEOUT
505520
)
@@ -578,7 +593,7 @@ async def to_bailian_data(files: List[FileSpec]) -> List[str]:
578593
continue
579594

580595
# Add file to form data
581-
with open(file_path, "rb", encoding="utf-8") as f:
596+
with open(file_path, "rb") as f:
582597
form_data.add_field(
583598
name="files",
584599
value=f.read(),

dashscope/finetune/reinforcement/component/demo/group_reward_processor_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from dashscope.finetune.reinforcement.component.data.base_data_model import (
1010
TaskStatus,
1111
)
12-
from dashscope.finetune.reinforcement.component.data.group_reward_output import (
12+
from dashscope.finetune.reinforcement.component.data.group_reward_input import (
1313
GroupRewardInput,
14+
)
15+
from dashscope.finetune.reinforcement.component.data.group_reward_output import (
1416
GroupRewardOutput,
1517
GroupReward,
1618
)

dashscope/finetune/reinforcement/component/func_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def process(self, input_data: RewardInput) -> RewardOutput:
139139
)
140140

141141
# If no aggregate function, use default weighted sum
142-
total = self.get_total()
142+
total = self.get_total(sub_rewards)
143143

144144
# Return RewardOutput with calculated total
145145
return RewardOutput(

dashscope/finetune/reinforcement/component/processor/abstract_group_reward_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from abc import abstractmethod
9+
import asyncio
910

1011
from dashscope.finetune.reinforcement.component.data.group_reward_input import (
1112
GroupRewardInput,

dashscope/finetune/reinforcement/component/processor/abstract_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from abc import ABC, abstractmethod
88
from typing import Any
9+
import asyncio
910

1011
from dashscope.finetune.reinforcement.component.data.base_data_model import (
1112
BaseDataModel,

dashscope/finetune/reinforcement/component/processor/abstract_reward_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, executor: Optional[Executor] = None):
6868
# IMPORTANT: Subclasses MUST call super().__init__() to ensure function collection
6969
self._collect_functions()
7070

71-
async def _collect_functions(self):
71+
def _collect_functions(self):
7272
"""Collect marked sub-functions and aggregate functions in the class"""
7373
# Prevent duplicate collection
7474
if self.functions_collected:

dashscope/finetune/reinforcement/component/processor/abstract_rollout_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from abc import abstractmethod
9+
import asyncio
910

1011
from dashscope.finetune.reinforcement.component.data.rollout_input import (
1112
RolloutInput,

0 commit comments

Comments
 (0)