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

Proposal: search automatically for local config-files/readers #286

Closed
sjoro opened this issue May 8, 2018 · 1 comment
Closed

Proposal: search automatically for local config-files/readers #286

sjoro opened this issue May 8, 2018 · 1 comment
Labels
enhancement code enhancements, features, improvements

Comments

@sjoro
Copy link
Collaborator

sjoro commented May 8, 2018

EUMETSAT has many Level 0, 1, and 2 products in different internal formats. These products are only used in-house and are not send out to the users. Therefore, satpy-readers for such products would quickly pollute satpy/etc/readers/-directory with *.yaml-files that are only useful for a small amount of PyTroll users.

The workaround with current implementation is to use ppp_config_dir-keyword when creating a Scene-object:

scn = Scene(fname, reader='my_reader', ppp_config_dir='/local/config/path')

This is a proposal for a possibility to add a local config directory where config files would be automatically searched. Proposed solution by modifying config_search_paths-method in satpy/config.py by setting an environmental variable, e.g. SATPY_LOCAL_CONFIG

Proposed modification

def config_search_paths(filename, *search_dirs, **kwargs):
    # Get the environment variable value every time (could be set dynamically)
    # FIXME: Consider removing the 'magic' environment variable all together
    CONFIG_PATH = get_environ_config_dir()
    LOCAL_PATH = os.environ.get('SATPY_LOCAL_CONFIG')
    paths = [filename, os.path.basename(filename)]
    paths += [os.path.join(search_dir, filename) for search_dir in search_dirs]
    if LOCAL_PATH:
        paths += [os.path.join(LOCAL_PATH, filename)]
    # FUTURE: Remove CONFIG_PATH because it should be included as a search_dir
    paths += [os.path.join(CONFIG_PATH, filename),
              os.path.join(PACKAGE_CONFIG_PATH, filename)]

    if kwargs.get("check_exists", True):
        paths = [x for x in paths if os.path.isfile(x)]

    # flip the order of the list so builtins are loaded first
    return paths[::-1]

Any ideas, comments, thoughts? Would such modification be useful for other institutes/organizations? Or is this just silly? ;)

@sjoro sjoro added the enhancement code enhancements, features, improvements label May 8, 2018
@sjoro
Copy link
Collaborator Author

sjoro commented May 8, 2018

The functionality can be achieved by pointing PPP_CONFIG_DIR-environmental variable to the local config path.

@sjoro sjoro closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement code enhancements, features, improvements
Projects
None yet
Development

No branches or pull requests

1 participant