mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-03 16:02:04 +00:00
streamlit cmdline fix for macs/conda
This commit is contained in:
@@ -10,8 +10,8 @@ from typing import List, Tuple
|
||||
import finviz
|
||||
import pandas as pd
|
||||
import praw
|
||||
from pmaw import PushshiftAPI
|
||||
from prawcore.exceptions import ResponseException
|
||||
from psaw import PushshiftAPI
|
||||
from requests import HTTPError
|
||||
from sklearn.feature_extraction import _stop_words
|
||||
from tqdm import tqdm
|
||||
|
||||
@@ -20,6 +20,7 @@ class Custom(PltTA):
|
||||
@indicator()
|
||||
def plot_srlines(self, fig: OpenBBFigure, df_ta: pd.DataFrame):
|
||||
"""Adds support and resistance lines to plotly figure"""
|
||||
window = self.params["srlines"].get_argument_values("window") or 200
|
||||
|
||||
def is_far_from_level(value, levels, df_stock):
|
||||
ave = np.mean(df_stock["High"] - df_stock["Low"])
|
||||
@@ -40,7 +41,7 @@ class Custom(PltTA):
|
||||
return cond1 and cond2 and cond3 and cond4
|
||||
|
||||
df_ta2 = df_ta.copy().loc[
|
||||
(df_ta.index >= datetime.now() - timedelta(days=200))
|
||||
(df_ta.index >= datetime.now() - timedelta(days=window))
|
||||
& (df_ta.index < datetime.now())
|
||||
]
|
||||
if df_ta2.index[-2].date() != df_ta2.index[-1].date():
|
||||
|
||||
@@ -321,7 +321,9 @@ class DashboardsController(BaseController):
|
||||
ns_parser = self.parse_simple_args(parser, other_args)
|
||||
|
||||
if ns_parser:
|
||||
cmd = "streamlit run"
|
||||
cmd = ["streamlit", "run", "--server.headless", "true"]
|
||||
if not hasattr(sys, "frozen"):
|
||||
cmd = [sys.executable, "-m"] + cmd
|
||||
|
||||
filepath = Path(__file__).parent / "stream" / "Forecasting.py"
|
||||
file = filepath.relative_to(self.parent_path).as_posix()
|
||||
@@ -333,7 +335,7 @@ class DashboardsController(BaseController):
|
||||
response = ""
|
||||
if not ns_parser.input and not self.streamlit_url:
|
||||
response = console.input(
|
||||
f"\nWarning: opens a port on your computer to run a {cmd} server.\n"
|
||||
"\nWarning: opens a port on your computer to run a streamlit server.\n"
|
||||
"[green]Would you like us to run the server for you Y/n? [/]"
|
||||
)
|
||||
|
||||
@@ -341,9 +343,10 @@ class DashboardsController(BaseController):
|
||||
port = self.get_free_port()
|
||||
self.streamlit_url = f"http://localhost:{port}"
|
||||
os.environ["PYTHONPATH"] = str(self.parent_path)
|
||||
cmd += ["--server.port", f"{port}", file]
|
||||
self.processes.append(
|
||||
psutil.Popen(
|
||||
f"{cmd} --server.headless true --server.port {port} {file}",
|
||||
cmd,
|
||||
stdout=PIPE,
|
||||
stderr=STDOUT,
|
||||
stdin=PIPE,
|
||||
@@ -376,7 +379,9 @@ class DashboardsController(BaseController):
|
||||
url = f"{self.streamlit_url}/{name}"
|
||||
plots_backend().send_url(url=url, title=f"{filename.title()} Dashboard")
|
||||
else:
|
||||
console.print(f"\n\nType: {cmd} '{file}'\ninto a terminal to run.")
|
||||
console.print(
|
||||
f"\n\nType: streamlit run '{file}'\ninto a terminal to run."
|
||||
)
|
||||
|
||||
|
||||
def is_streamlit_activated() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user