2025-09-18 11:10:12 +08:00
from pathlib import Path
2025-04-09 23:24:12 +08:00
from typing import Literal
2025-03-05 18:30:02 +08:00
from pydantic_settings import SettingsConfigDict
2025-01-17 22:53:05 +08:00
from rdagent.app.kaggle.conf import KaggleBasePropSetting
class DataScienceBasePropSetting ( KaggleBasePropSetting ):
2025-05-06 16:00:13 +08:00
# TODO: Kaggle Setting should be the subclass of DataScience
2025-03-05 18:30:02 +08:00
model_config = SettingsConfigDict ( env_prefix = "DS_" , protected_namespaces = ())
2025-01-17 22:53:05 +08:00
# Main components
## Scen
scen : str = "rdagent.scenarios.data_science.scen.KaggleScen"
2025-06-17 14:55:11 +08:00
"""
Scenario class for data science tasks.
- For Kaggle competitions, use: "rdagent.scenarios.data_science.scen.KaggleScen"
- For custom data science scenarios, use: "rdagent.scenarios.data_science.scen.DataScienceScen"
"""
2025-01-17 22:53:05 +08:00
2025-07-23 12:20:06 +08:00
planner : str = "rdagent.scenarios.data_science.proposal.exp_gen.planner.DSExpPlannerHandCraft"
hypothesis_gen : str = "rdagent.scenarios.data_science.proposal.exp_gen.router.ParallelMultiTraceExpGen"
2025-09-18 11:10:12 +08:00
interactor : str = "rdagent.components.interactor.SkipInteractor"
2025-08-06 16:42:51 +08:00
trace_scheduler : str = "rdagent.scenarios.data_science.proposal.exp_gen.trace_scheduler.RoundRobinScheduler"
2025-05-09 15:38:25 +08:00
"""Hypothesis generation class"""
2025-07-09 18:36:42 +08:00
summarizer : str = "rdagent.scenarios.data_science.dev.feedback.DSExperiment2Feedback"
summarizer_init_kwargs : dict = {
"version" : "exp_feedback" ,
}
2025-01-24 15:03:21 +08:00
## Workflow Related
2025-01-24 13:34:47 +08:00
consecutive_errors : int = 5
2025-04-30 17:36:35 +08:00
## Coding Related
coding_fail_reanalyze_threshold : int = 3
2025-07-31 16:47:19 +08:00
debug_recommend_timeout : int = 600
"""The recommend time limit for running on debugging data"""
2025-01-24 15:03:21 +08:00
debug_timeout : int = 600
"""The timeout limit for running on debugging data"""
2025-07-31 16:47:19 +08:00
full_recommend_timeout : int = 3600
"""The recommend time limit for running on full data"""
2025-01-24 15:03:21 +08:00
full_timeout : int = 3600
"""The timeout limit for running on full data"""
2025-08-27 18:36:51 +08:00
#### model dump
enable_model_dump : bool = False
enable_doc_dev : bool = False
model_dump_check_level : Literal [ "medium" , "high" ] = "medium"
2025-09-13 10:25:02 +08:00
#### MCP documentation search integration
enable_mcp_documentation_search : bool = False
"""Enable MCP documentation search for error resolution. Requires MCP_ENABLED=true and MCP_CONTEXT7_ENABLED=true in environment."""
2025-03-27 17:17:41 +08:00
### specific feature
2025-08-05 03:06:57 -07:00
### notebook integration
enable_notebook_conversion : bool = False
2025-03-27 17:17:41 +08:00
#### enable specification
spec_enabled : bool = True
2025-05-06 16:00:13 +08:00
#### proposal related
2025-07-08 15:22:39 +08:00
# proposal_version: str = "v2" deprecated
coder_on_whole_pipeline : bool = True
2025-04-07 13:01:29 +08:00
max_trace_hist : int = 3
2025-04-02 13:37:47 +08:00
2025-04-02 00:18:42 -06:00
coder_max_loop : int = 10
2025-07-10 18:10:32 +08:00
runner_max_loop : int = 3
2025-04-02 00:18:42 -06:00
2025-07-10 18:10:32 +08:00
sample_data_by_LLM : bool = True
2025-05-06 16:00:13 +08:00
use_raw_description : bool = False
2025-05-10 17:02:12 +08:00
show_nan_columns : bool = False
2025-04-08 03:27:21 -06:00
2025-04-18 14:01:03 +08:00
### knowledge base
enable_knowledge_base : bool = False
knowledge_base_version : str = "v1"
knowledge_base_path : str | None = None
idea_pool_json_path : str | None = None
### archive log folder after each loop
enable_log_archive : bool = True
log_archive_path : str | None = None
log_archive_temp_path : str | None = (
None # This is to store the mid tar file since writing the tar file is preferred in local storage then copy to target storage
)
2025-05-06 16:00:13 +08:00
#### Evaluation on Test related
eval_sub_dir : str = "eval" # TODO: fixme, this is not a good name
"""We'll use f" {DS_RD_SETTING.local_data_path} / {DS_RD_SETTING.eval_sub_dir} / {competition} "
to find the scriipt to evaluate the submission on test"""
2025-05-19 17:59:42 +08:00
"""---below are the settings for multi-trace---"""
### multi-trace related
2025-08-18 12:13:23 +08:00
max_trace_num : int = 1
2025-05-19 17:59:42 +08:00
"""The maximum number of traces to grow before merging"""
2025-08-06 16:42:51 +08:00
scheduler_temperature : float = 1.0
"""The temperature for the trace scheduler for softmax calculation, used in ProbabilisticScheduler"""
2025-10-17 16:21:39 +08:00
# PUCT exploration constant for MCTSScheduler (ignored by other schedulers)
scheduler_c_puct : float = 1.0
"""Exploration constant used by MCTSScheduler (PUCT)."""
enable_score_reward : bool = False
"""Enable using score-based reward for trace selection in multi-trace scheduling."""
2025-05-19 17:59:42 +08:00
#### multi-trace:checkpoint selector
2025-07-11 17:42:40 +08:00
selector_name : str = "rdagent.scenarios.data_science.proposal.exp_gen.select.expand.LatestCKPSelector"
2025-05-19 17:59:42 +08:00
"""The name of the selector to use"""
sota_count_window : int = 5
"""The number of trials to consider for SOTA count"""
sota_count_threshold : int = 1
"""The threshold for SOTA count"""
#### multi-trace: SOTA experiment selector
2025-07-11 17:42:40 +08:00
sota_exp_selector_name : str = "rdagent.scenarios.data_science.proposal.exp_gen.select.submit.GlobalSOTASelector"
2025-05-19 17:59:42 +08:00
"""The name of the SOTA experiment selector to use"""
### multi-trace:inject optimals for multi-trace
# inject diverse when start a new sub-trace
2025-05-09 15:38:25 +08:00
enable_inject_diverse : bool = False
2025-08-18 12:43:21 +08:00
# inject diverse from other traces when start a new sub-trace
enable_cross_trace_diversity : bool = True
"""Enable cross-trace diversity injection when starting a new sub-trace.
This is different from `enable_inject_diverse` which is for non-parallel cases."""
diversity_injection_strategy : str = (
"rdagent.scenarios.data_science.proposal.exp_gen.diversity_strategy.InjectUntilSOTAGainedStrategy"
)
"""The strategy to use for injecting diversity context."""
2025-06-11 23:13:30 +08:00
# enable different version of DSExpGen for multi-trace
enable_multi_version_exp_gen : bool = False
exp_gen_version_list : str = "v3,v2"
2025-05-19 17:59:42 +08:00
#### multi-trace: time for final multi-trace merge
2025-08-27 18:36:51 +08:00
merge_hours : float = 0
2025-05-19 17:59:42 +08:00
"""The time for merge"""
2025-05-22 16:10:00 +08:00
#### multi-trace: max SOTA-retrieved number, used in AutoSOTAexpSelector
# constrains the number of SOTA experiments to retrieve, otherwise too many SOTA experiments to retrieve will cause the exceed of the context window of LLM
max_sota_retrieved_num : int = 10
"""The maximum number of SOTA experiments to retrieve in a LLM call"""
2025-07-23 12:20:06 +08:00
#### enable draft before first sota experiment
enable_draft_before_first_sota : bool = False
enable_planner : bool = False
model_architecture_suggestion_time_percent : float = 0.75
2025-07-29 14:59:38 +08:00
allow_longer_timeout : bool = False
2025-08-27 18:36:51 +08:00
coder_enable_llm_decide_longer_timeout : bool = False
runner_enable_llm_decide_longer_timeout : bool = False
2025-07-31 13:06:28 +08:00
coder_longer_timeout_multiplier_upper : int = 3
runner_longer_timeout_multiplier_upper : int = 2
2025-08-27 18:36:51 +08:00
coder_timeout_increase_stage : float = 0.3
2025-09-03 16:37:33 +08:00
runner_timeout_increase_stage : float = 0.3
runner_timeout_increase_stage_patience : int = 2
"""Number of failures tolerated before escalating to next timeout level (stage width). Every 'patience' failures, timeout increases by 'runner_timeout_increase_stage'"""
2025-08-01 18:32:15 +08:00
show_hard_limit : bool = True
2025-07-23 12:20:06 +08:00
2025-08-27 18:36:51 +08:00
#### enable runner code change summary
runner_enable_code_change_summary : bool = True
### Proposal workflow related
#### Hypothesis Generate related
enable_simple_hypothesis : bool = False
"""If true, generate simple hypothesis, no more than 2 sentences each."""
enable_generate_unique_hypothesis : bool = False
"""Enable generate unique hypothesis. If True, generate unique hypothesis for each component. If False, generate unique hypothesis for each component."""
2025-10-20 16:46:25 +08:00
enable_research_rag : bool = False
"""Enable research RAG for hypothesis generation."""
2025-07-29 14:20:09 +08:00
#### hypothesis critique and rewrite
2025-08-27 18:36:51 +08:00
enable_hypo_critique_rewrite : bool = False
2025-07-29 14:20:09 +08:00
"""Enable hypothesis critique and rewrite stages for improving hypothesis quality"""
2025-07-31 13:06:28 +08:00
enable_scale_check : bool = False
2025-07-29 14:20:09 +08:00
2025-08-27 18:36:51 +08:00
##### select related
ratio_merge_or_ensemble : int = 70
"""The ratio of merge or ensemble to be considered as a valid solution"""
llm_select_hypothesis : bool = False
"""Whether to use LLM to select hypothesis. If True, use LLM selection; if False, use the existing ranking method."""
#### Task Generate related
fix_seed_and_data_split : bool = False
2025-08-04 17:38:27 +08:00
2025-09-08 16:35:42 +08:00
ensemble_time_upper_bound : bool = False
2025-09-18 11:10:12 +08:00
user_interaction_wait_seconds : int = 6000 # seconds to wait for user interaction
user_interaction_mid_folder : Path = Path . cwd () / "git_ignore_folder" / "RD-Agent_user_interaction"
2025-01-17 22:53:05 +08:00
DS_RD_SETTING = DataScienceBasePropSetting ()
2025-08-27 18:36:51 +08:00
2025-09-13 10:25:02 +08:00
# enable_cross_trace_diversity and llm_select_hypothesis should not be true at the same time
2025-08-27 18:36:51 +08:00
assert not (
DS_RD_SETTING . enable_cross_trace_diversity and DS_RD_SETTING . llm_select_hypothesis
), "enable_cross_trace_diversity and llm_select_hypothesis cannot be true at the same time"