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

Filename from environment variable in save #38

Open
dojeda opened this issue Jan 22, 2020 · 1 comment
Open

Filename from environment variable in save #38

dojeda opened this issue Jan 22, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@dojeda
Copy link
Contributor

dojeda commented Jan 22, 2020

On three separate occasions, I have needed to set the exact name of a filename in a Save node, instead of the auto-generated one. In particular, I needed to have an HDF5 and a log file with matching names. Since the log filename is already configurable through an environment variable, I kept this approach. For this use case, I created a workaround node that does as follows:

import os

from timeflux.nodes.hdf5 import Save as TimefluxSave


class Save(TimefluxSave):

    def __init__(self, *, path_env=None, filename_env=None, **kwargs):
        if path_env is not None:
            path = os.getenv(path_env, None)
            if path is not None:
                kwargs.setdefault('path', path)

        if filename_env is not None:
            filename = os.getenv(filename_env, None)
            kwargs.setdefault('filename', filename)

        super().__init__(**kwargs)

Will you be interested in creating an improvement on the timeflux.nodes.hdf5.Save node to add this behavior?

@mesca
Copy link
Member

mesca commented Jan 22, 2020

Using environment variables is definitely the right approach, and I want to expand on that idea. Instead of implementing the behavior you propose at the node level, why would not we apply this at the graph level? We could have strings like ${MY_VAR} in params, and have them parsed in the manager or the worker. We could also define a bunch of generic env vars like ${DATETIME}, ${ROOT}, etc.

@mesca mesca added the enhancement New feature or request label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants