pepkit / peppy

Project metadata manager for PEPs in Python
https://pep.databio.org/peppy
BSD 2-Clause "Simplified" License
37 stars 13 forks source link

restructure peppy constructor function (init) #465

Open khoroshevskyi opened 10 months ago

khoroshevskyi commented 10 months ago

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
        ...
nsheff commented 7 months ago

actually, we should use class methods, like Project.from_pandas and Project.from_pephub, etc.

nsheff commented 3 months ago

@donaldcampbelljr I think this may also be needed for your work using peppy's import to implement the looper config embedded pep.

donaldcampbelljr commented 3 months ago

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.

nsheff commented 3 months ago

I really want to be able to do something like this:

import peppy

prj = peppy.Project.from_pephub("nsheff/mypep:default")