OpenBB icon indicating copy to clipboard operation
OpenBB copied to clipboard

Added files outside OpenBB

Open colin99d opened this issue 2 years ago • 6 comments

Description

Creates an OpenBB folder in the home directory and adds required files insider. This PR will also look to change openbb_terminal/core/config/constants.py to the single source of truth for referencing files. Fixes #2453 Still need to do:

  • [x] Actually use the new custom_imports folder
  • [x] Actually export to the new exports folder
  • [ ] Actually read from new other folders

How has this been tested?

  • Please describe the tests that you ran to verify your changes.
  • Provide instructions so we can reproduce.
  • Please also list any relevant details for your test configuration.

Checklist:

Others

  • [ ] I have performed a self-review of my own code.
  • [ ] I have commented my code, particularly in hard-to-understand areas.
  • [ ] My code passes all the checks pylint, flake8, black, ... To speed up development you should run pre-commit install.
  • [ ] New and existing unit tests pass locally with my changes. You can test this locally using pytest tests/....

colin99d avatar Aug 26 '22 20:08 colin99d

A few checks:

  • What happens when I do a fresh install (both Python and Installer), does it overwrite these files? E.g. will I still lose all my API keys?
  • Can there be a confirmation window of some kind that says "The folder already exists, do you wish to overwrite?"
  • Does this work for importing and exporting files?
  • Does this also work for functionalities that look at certain folders (e.g. Econometrics load) and is this correctly redirected?

This also addresses the unfortunate loss of API keys mentioned here #2453

JerBouma avatar Aug 30 '22 10:08 JerBouma

  • What happens when I do a fresh install (both Python and Installer), does it overwrite these files? E.g. will I still lose all my API keys? It checks if folders already exist before creating them, so old files will never be overwritten
  • Can there be a confirmation window of some kind that says "The folder already exists, do you wish to overwrite?" Same answer as above
  • Does this work for importing and exporting files? Importing works, still need to testing exporting. I dont beleive style, routing, and ini files work yet
  • Does this also work for functionalities that look at certain folders (e.g. Econometrics load) and is this correctly redirected? Econometrics load works with this, forecast will be modified once this is merged This also addresses the unfortunate loss of API keys mentioned here #2453

colin99d avatar Aug 30 '22 12:08 colin99d

It is important to note that since some of the functions this uses are conditional on whether the given terminal is an installer, this will not be fully tested until we generate an installer with this code.

colin99d avatar Sep 02 '22 07:09 colin99d

USER_DATA_DIR = Path(str(Path.home()) + "/OpenBBUserData")
if not os.path.exists(USER_DATA_DIR):
    os.mkdir(USER_DATA_DIR)

USER_HOME = Path(os.path.expanduser("~"))
ENV_FILE_DIR = Path(str(Path.home()) + "/.openbb_terminal")
if not os.path.exists(ENV_FILE_DIR):
    os.mkdir(ENV_FILE_DIR)

ENV_FILE = ENV_FILE_DIR.joinpath(".env")
if not ENV_FILE.is_file():
    with open(str(ENV_FILE), "w"):
        pass

Also, is there a reason we have a separate folder for just the env variable? Especially since this file is hidden by file browsers by default.

colin99d avatar Sep 02 '22 08:09 colin99d

USER_DATA_DIR = Path(str(Path.home()) + "/OpenBBUserData")
if not os.path.exists(USER_DATA_DIR):
    os.mkdir(USER_DATA_DIR)

USER_HOME = Path(os.path.expanduser("~"))
ENV_FILE_DIR = Path(str(Path.home()) + "/.openbb_terminal")
if not os.path.exists(ENV_FILE_DIR):
    os.mkdir(ENV_FILE_DIR)

ENV_FILE = ENV_FILE_DIR.joinpath(".env")
if not ENV_FILE.is_file():
    with open(str(ENV_FILE), "w"):
        pass

Also, is there a reason we have a separate folder for just the env variable? Especially since this file is hidden by file browsers by default.

This was something @piiq and @Chavithra suggested since we don't really want the user to have direct access to the .env file and instead set it using the keys or settings menu

Also, another thing that was suggested is instead of having an openbb timezone file, we could add it as a variable in the .env file

soggyomelette avatar Sep 02 '22 10:09 soggyomelette

Also, is there a reason we have a separate folder for just the env variable?

@colin99d The user is able to define any folder to be a OpenBBUserData folder. This setting is saved as a record in the .env file. When a new updated version is installed/cloned the new code doesn't know where to look for the location of the user data folder. Splitting user data and the settings file is to solve this issue. User level settings are saved in .* files by in user home by many programs. My user home includes a lot of stuff including image

So as you can see by .gamestonk_terminal.hist` we're already utilizing that place for quite some time

piiq avatar Sep 02 '22 10:09 piiq