Skip to content
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

chore: change log object #553

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Start the flask server before running the demo.
  • Loading branch information
SunsetWolf committed Feb 28, 2025
commit 2f1c1a28d3675006465f53861ab839a328b3cc52
59 changes: 46 additions & 13 deletions rdagent/app/cli.py
Original file line number Diff line number Diff line change
@@ -13,9 +13,11 @@
# 2) The ".env" argument is necessary to make sure it loads `.env` from the current directory.

import subprocess
import time
from importlib.resources import path as rpath

import fire
import requests

from rdagent.app.data_mining.model import main as med_model
from rdagent.app.general_model.general_model import (
@@ -27,6 +29,7 @@
from rdagent.app.qlib_rd_loop.model import main as fin_model
from rdagent.app.utils.health_check import health_check
from rdagent.app.utils.info import collect_info
from rdagent.log import rdagent_logger as logger


def ui(port=19899, log_dir="", debug=False):
@@ -44,17 +47,47 @@ def ui(port=19899, log_dir="", debug=False):
subprocess.run(cmds)


def app():
fire.Fire(
{
"fin_factor": fin_factor,
"fin_factor_report": fin_factor_report,
"fin_model": fin_model,
"med_model": med_model,
"general_model": general_model,
"ui": ui,
"health_check": health_check,
"collect_info": collect_info,
"kaggle": kaggle_main,
}
def start_flask_server():
"""
Start the Flask server and make sure it is running in the background without affecting the main process.
"""
flask_process = subprocess.Popen(
["python", "rdagent/log/server/app.py"],
# Hide Output
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
# Standard Output
# stdout=sys.stdout,
# stderr=sys.stderr,
)
flask_url = "http://127.0.0.1:19899"
for _ in range(6):
try:
response = requests.get(flask_url, timeout=1)
if response.status_code == 200:
logger.info(f"The Flask server started successfully. Running on: {flask_url}")
return flask_process
except requests.exceptions.RequestException:
time.sleep(1)
logger.error("❌ Flask server startup failed, please check manually!")


def app():
flask_process = start_flask_server()
try:
fire.Fire(
{
"fin_factor": fin_factor,
"fin_factor_report": fin_factor_report,
"fin_model": fin_model,
"med_model": med_model,
"general_model": general_model,
"ui": ui,
"health_check": health_check,
"collect_info": collect_info,
"kaggle": kaggle_main,
}
)
finally:
# Terminate the Flask process to prevent it from running after `app()` exits.
flask_process.terminate()
Loading
Oops, something went wrong.