Closed nsheff closed 1 week ago
Is this actually already possible? Looks as though we are using priority_get
to potentially use any environment variables:
https://github.com/pepkit/pipestat/blob/e7d42370aaf01267956fedb426ba16d6d73b3be0/pipestat/pipestat.py#L187-L210
I did confirm that this works fine. The only snag I ran into was sourcing my .env
file. I found a package that assisted with this in Python.
https://github.com/theskumar/python-dotenv
Example of Code, assuming main.py
and .env
are parallel:
from pipestat import PipestatManager
from dotenv import load_dotenv
load_dotenv()
psm1=PipestatManager()
psm1.report(values={"number_of_things":3})
Here I have an example of some code that allows a database-backed Python object to be parameterized either via constructor, or via ENV vars:
https://github.com/refgenie/seqcolapi/blob/fa889f818e1858573cb261077fd737af905178af/seqcolapi/scconf.py#L79-L94
I have found this convenient, because to use it I just do something like:
Then
which is quite nice, and also cloud-friendly. I have found myself wanting to do this with pipestat. Would it be possible to make the constructor work like this so it can be configured via ENV vars?
I know it's a little different since there's a pipestat config file, and there's nothing like that here.
I wonder if
priority_get
could help;https://github.com/databio/yacman/blob/5db6323a6469347abfa16a590fc8b48d21b7b16f/yacman/yacman_future.py#L358-L389