mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-06 01:12:27 +00:00
Merge branch 'develop' into release/3.2.0
This commit is contained in:
@@ -314,6 +314,14 @@ class AccountController(BaseController):
|
||||
default="",
|
||||
nargs="+",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--public",
|
||||
dest="public",
|
||||
action="store_true",
|
||||
help="Whether the routine should be public or not",
|
||||
default=False,
|
||||
)
|
||||
ns_parser = self.parse_known_args_and_warn(parser, other_args)
|
||||
if is_local() and "-h" not in other_args and "--help" not in other_args:
|
||||
print_guest_block_msg()
|
||||
@@ -341,6 +349,7 @@ class AccountController(BaseController):
|
||||
"description": description,
|
||||
"routine": routine,
|
||||
"tags": tags,
|
||||
"public": ns_parser.public,
|
||||
}
|
||||
response = Hub.upload_routine(**kwargs) # type: ignore
|
||||
|
||||
|
||||
@@ -396,6 +396,7 @@ def upload_config(
|
||||
return None
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def upload_routine(
|
||||
auth_header: str,
|
||||
name: str = "",
|
||||
@@ -403,6 +404,7 @@ def upload_routine(
|
||||
routine: str = "",
|
||||
override: bool = False,
|
||||
tags: str = "",
|
||||
public: bool = False,
|
||||
base_url: str = BASE_URL,
|
||||
timeout: int = TIMEOUT,
|
||||
) -> Optional[requests.Response]:
|
||||
@@ -420,6 +422,8 @@ def upload_routine(
|
||||
Whether to override the routine if it already exists.
|
||||
tags : str
|
||||
The tags of the routine.
|
||||
public : bool
|
||||
Whether to make the routine public or not.
|
||||
base_url : str
|
||||
The base url, by default BASE_URL
|
||||
timeout : int
|
||||
@@ -430,7 +434,6 @@ def upload_routine(
|
||||
Optional[requests.Response]
|
||||
The response from the post request.
|
||||
"""
|
||||
|
||||
data = {
|
||||
"name": name,
|
||||
"description": description,
|
||||
@@ -438,7 +441,7 @@ def upload_routine(
|
||||
"override": override,
|
||||
"tags": tags,
|
||||
"version": get_current_system().VERSION,
|
||||
"public": False,
|
||||
"public": public,
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@@ -82,11 +82,14 @@ CRYPTO_SOURCES = {
|
||||
|
||||
SUPPORT_TYPE = ["bug", "suggestion", "question", "generic"]
|
||||
|
||||
|
||||
# TODO: We should try to avoid these global variables
|
||||
RECORD_SESSION = False
|
||||
SESSION_RECORDED = list()
|
||||
SESSION_RECORDED_NAME = ""
|
||||
SESSION_RECORDED_DESCRIPTION = ""
|
||||
SESSION_RECORDED_TAGS = ""
|
||||
SESSION_RECORDED_PUBLIC = False
|
||||
|
||||
|
||||
class BaseController(metaclass=ABCMeta):
|
||||
@@ -910,6 +913,14 @@ class BaseController(metaclass=ABCMeta):
|
||||
default="",
|
||||
nargs="+",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--public",
|
||||
dest="public",
|
||||
action="store_true",
|
||||
help="Whether the routine should be public or not",
|
||||
default=False,
|
||||
)
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
other_args.insert(0, "-n")
|
||||
ns_parser = self.parse_simple_args(parser, other_args)
|
||||
@@ -919,6 +930,7 @@ class BaseController(metaclass=ABCMeta):
|
||||
global SESSION_RECORDED_NAME
|
||||
global SESSION_RECORDED_DESCRIPTION
|
||||
global SESSION_RECORDED_TAGS
|
||||
global SESSION_RECORDED_PUBLIC
|
||||
|
||||
SESSION_RECORDED_NAME = (
|
||||
ns_parser.name
|
||||
@@ -928,6 +940,7 @@ class BaseController(metaclass=ABCMeta):
|
||||
|
||||
SESSION_RECORDED_DESCRIPTION = " ".join(ns_parser.description)
|
||||
SESSION_RECORDED_TAGS = " ".join(ns_parser.tags) if ns_parser.tags else ""
|
||||
SESSION_RECORDED_PUBLIC = ns_parser.public
|
||||
|
||||
console.print(
|
||||
"[green]The session is successfully being recorded."
|
||||
@@ -980,6 +993,7 @@ class BaseController(metaclass=ABCMeta):
|
||||
"description": SESSION_RECORDED_DESCRIPTION,
|
||||
"routine": routine,
|
||||
"tags": SESSION_RECORDED_TAGS,
|
||||
"public": SESSION_RECORDED_PUBLIC,
|
||||
}
|
||||
response = Hub.upload_routine(**kwargs) # type: ignore
|
||||
if response is not None and response.status_code == 409:
|
||||
|
||||
@@ -442,6 +442,7 @@ def test_call_upload(mocker, test_user):
|
||||
description="abc",
|
||||
routine="do something",
|
||||
tags="stocks",
|
||||
public=False,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@ qtd,-
|
||||
ytd,-
|
||||
3m,-
|
||||
6m,-
|
||||
1y,"Adj Close NaN
|
||||
Total NaN
|
||||
dtype: float64"
|
||||
1y,-
|
||||
3y,"Adj Close NaN
|
||||
Total NaN
|
||||
dtype: float64"
|
||||
|
||||
|
@@ -534,14 +534,45 @@ def test_clear_user_configs_exception():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"auth_header, name, description, routine, override, base_url, timeout, status_code",
|
||||
"auth_header, name, description, routine, override, tags, public, base_url, timeout, status_code",
|
||||
[
|
||||
("auth_header", "name", "description", "routine", True, "base_url", 10, 200),
|
||||
("auth_header", "name", "description", "routine", False, "base_url", 10, 400),
|
||||
(
|
||||
"auth_header",
|
||||
"name",
|
||||
"description",
|
||||
"routine",
|
||||
True,
|
||||
"TEST_TAG",
|
||||
True,
|
||||
"base_url",
|
||||
10,
|
||||
200,
|
||||
),
|
||||
(
|
||||
"auth_header",
|
||||
"name",
|
||||
"description",
|
||||
"routine",
|
||||
False,
|
||||
"TEST_TAG",
|
||||
False,
|
||||
"base_url",
|
||||
10,
|
||||
400,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_upload_routine(
|
||||
auth_header, name, description, routine, override, base_url, timeout, status_code
|
||||
auth_header,
|
||||
name,
|
||||
description,
|
||||
routine,
|
||||
override,
|
||||
tags,
|
||||
public,
|
||||
base_url,
|
||||
timeout,
|
||||
status_code,
|
||||
):
|
||||
mock_response = MagicMock(spec=requests.Response)
|
||||
mock_response.status_code = status_code
|
||||
@@ -555,6 +586,8 @@ def test_upload_routine(
|
||||
name=name,
|
||||
description=description,
|
||||
routine=routine,
|
||||
tags=tags,
|
||||
public=public,
|
||||
override=override,
|
||||
base_url=base_url,
|
||||
timeout=timeout,
|
||||
|
||||
Reference in New Issue
Block a user