mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 21:42:22 +00:00
Some error handling (#5357)
This commit is contained in:
committed by
Igor Radovanovic
parent
77716b2081
commit
9d70bc7da1
@@ -201,6 +201,8 @@ class EconometricsController(BaseController):
|
||||
choices["about"] = self.ABOUT_CHOICES
|
||||
choices["panel"]["-r"] = {c: {} for c in self.PANEL_CHOICES}
|
||||
self.completer = NestedCompleter.from_nested_dict(choices)
|
||||
else:
|
||||
self.choices = {}
|
||||
|
||||
def update_runtime_choices(self):
|
||||
if session and get_current_user().preferences.USE_PROMPT_TOOLKIT:
|
||||
@@ -656,7 +658,7 @@ class EconometricsController(BaseController):
|
||||
"-n",
|
||||
"--name",
|
||||
type=str,
|
||||
choices=self.choices["desc"],
|
||||
choices=self.choices.get("desc", []),
|
||||
dest="name",
|
||||
help="The name of the dataset.column you want to show the descriptive statistics",
|
||||
required="-h" not in other_args,
|
||||
@@ -765,7 +767,7 @@ class EconometricsController(BaseController):
|
||||
type=str,
|
||||
dest="name",
|
||||
help="Provide dataset.column series to change type or dataset to see types.",
|
||||
choices=self.choices["type"],
|
||||
choices=self.choices.get("type", []),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--format",
|
||||
@@ -1088,7 +1090,7 @@ class EconometricsController(BaseController):
|
||||
else:
|
||||
pd.eval(
|
||||
f"{new_column} = self.datasets[dataset2][existing_column] "
|
||||
f"{ns_parser.sign} {ns_parser.criteriaordatasetcol}",
|
||||
f"{ns_parser.sign} {str(ns_parser.criteriaordatasetcol)}",
|
||||
target=self.datasets[dataset],
|
||||
inplace=True,
|
||||
)
|
||||
@@ -1256,7 +1258,7 @@ class EconometricsController(BaseController):
|
||||
help="The columns you want to delete from a dataset. Use format: <dataset.column> or"
|
||||
" multiple with <dataset.column>,<dataset.column2>",
|
||||
dest="delete",
|
||||
type=check_list_values(self.choices["delete"]),
|
||||
type=check_list_values(self.choices.get("delete", [])),
|
||||
)
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
other_args.insert(0, "-d")
|
||||
@@ -1297,14 +1299,14 @@ class EconometricsController(BaseController):
|
||||
"--dataset",
|
||||
help="Dataset to add columns to",
|
||||
dest="dataset",
|
||||
choices=self.choices["combine"],
|
||||
choices=self.choices.get("combine", []),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--columns",
|
||||
help="The columns we want to add <dataset.column>,<dataset.column2>",
|
||||
dest="columns",
|
||||
type=check_list_values(self.choices["delete"]),
|
||||
type=check_list_values(self.choices.get("delete", [])),
|
||||
)
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
other_args.insert(0, "-d")
|
||||
@@ -1354,7 +1356,7 @@ class EconometricsController(BaseController):
|
||||
"--dataset",
|
||||
help="Dataset that will get a column renamed",
|
||||
dest="dataset",
|
||||
choices=self.choices["rename"],
|
||||
choices=self.choices.get("rename", []),
|
||||
type=str,
|
||||
)
|
||||
parser.add_argument(
|
||||
@@ -1421,7 +1423,7 @@ class EconometricsController(BaseController):
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--independent",
|
||||
type=check_list_values(self.choices["regressions"]),
|
||||
type=check_list_values(self.choices.get("regressions", [])),
|
||||
dest="independent",
|
||||
help=(
|
||||
"The independent variables on the regression you would like to perform. "
|
||||
@@ -1449,7 +1451,7 @@ class EconometricsController(BaseController):
|
||||
"Please select one.\nDid you intend to include these variables as independent "
|
||||
f"variables? Use -i {ns_parser.dependent} in this case.\n"
|
||||
)
|
||||
elif ns_parser.dependent in self.choices["regressions"]:
|
||||
elif ns_parser.dependent in self.choices.get("regressions", []):
|
||||
(
|
||||
regression_df,
|
||||
dependent_variable,
|
||||
@@ -1472,7 +1474,7 @@ class EconometricsController(BaseController):
|
||||
|
||||
else:
|
||||
console.print(
|
||||
f"{ns_parser.dependent} not in {','.join(self.choices['regressions'])}\n"
|
||||
f"{ns_parser.dependent} not in {','.join(self.choices.get('regressions', []))}\n"
|
||||
f"Please choose a valid dataset and column combination.\n"
|
||||
)
|
||||
|
||||
@@ -1489,7 +1491,7 @@ class EconometricsController(BaseController):
|
||||
"-v",
|
||||
"--value",
|
||||
type=str,
|
||||
choices=self.choices["norm"],
|
||||
choices=self.choices.get("norm", []),
|
||||
dest="column",
|
||||
help="The dataset.column you want to test normality for",
|
||||
required="-h" not in other_args,
|
||||
@@ -1547,7 +1549,7 @@ class EconometricsController(BaseController):
|
||||
"-v",
|
||||
"--value",
|
||||
type=str,
|
||||
choices=self.choices["root"],
|
||||
choices=self.choices.get("root", []),
|
||||
dest="column",
|
||||
help="The column and name of the database you want test unit root for",
|
||||
required="-h" not in other_args,
|
||||
@@ -1631,7 +1633,7 @@ class EconometricsController(BaseController):
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--independent",
|
||||
type=check_list_values(self.choices["regressions"]),
|
||||
type=check_list_values(self.choices.get("regressions", [])),
|
||||
dest="independent",
|
||||
help=(
|
||||
"The independent variables on the regression you would like to perform. "
|
||||
@@ -1680,7 +1682,7 @@ class EconometricsController(BaseController):
|
||||
"The model only accepts one.\nDid you intend to include these variables as independent "
|
||||
f"variables? Use -i {ns_parser.dependent} in this case.\n"
|
||||
)
|
||||
elif ns_parser.dependent in self.choices["regressions"]:
|
||||
elif ns_parser.dependent in self.choices.get("regressions", []):
|
||||
regression_vars = [ns_parser.dependent] + ns_parser.independent
|
||||
|
||||
if regression_vars and len(regression_vars) > 1:
|
||||
@@ -1919,7 +1921,7 @@ class EconometricsController(BaseController):
|
||||
"-v",
|
||||
"--value",
|
||||
type=str,
|
||||
choices=self.choices["garch"],
|
||||
choices=self.choices.get("garch", []),
|
||||
dest="column",
|
||||
help="The column and name of the database you want to estimate volatility for",
|
||||
required="-h" not in other_args,
|
||||
|
||||
Reference in New Issue
Block a user