peppy
peppy copied to clipboard
restructure peppy constructor function (init)
The peppy Project constructor was initially designed to expect a project in the form of a YAML+CSV file, a CSV file, or None. This approach was conceived before considering peppy
as a dictionary or another Python representation.
With the introduction of Pephub
and other new packages, there is now a need to initialize the Project using alternative methods, such as pandas, dictionaries, YAML, etc. To accommodate this, we should restructure the __init__
method to accept three Python objects instead of a configuration (cfg
) string. For example:
def __init__(self,
project_config: dict,
sample_table: pd.DataFrame,
subsample_list: Union[List, None] = None
amendments: Union[str, Iterable[str]] = None,
...
):
self.project_config = project_config
self.sample_table = sample_table
self.subsample_table = subsample_table
self.amendments = amendments
...
actually, we should use class methods, like Project.from_pandas
and Project.from_pephub
, etc.
@donaldcampbelljr I think this may also be needed for your work using peppy's import
to implement the looper config embedded pep.
Yes, the issue I'm running into with https://github.com/pepkit/looper/issues/270:
So, my workaround to create a temp PEP, convert to a dict, update the dict with the Looper-modified values, and then initialize Peppy project from dict still does not work as desired because the re-initialization using _from_dict() does not handle all import/ammendments unlike the main initialization via a cfg file.
I really want to be able to do something like this:
import peppy
prj = peppy.Project.from_pephub("nsheff/mypep:default")