seqeralabs / seqera-kit

Python implementation and field-tool for automated pipeline launching through Tower CLI (beta)
Apache License 2.0
25 stars 6 forks source link

return python objects instead of text #162

Open sstrong99 opened 3 weeks ago

sstrong99 commented 3 weeks ago

It would be nice if commands like compute-envs list returned python objects instead of strings that need to be parsed to get the data. e.g.

from seqerakit import seqeraplatform
tw = seqeraplatform.SeqeraPlatform()
out = tw.compute_envs("list")

"""
here `out` could be a list of dicts like 
out = [
    {
        "id": ...,
        "status": ...,
        "platform": ...,
        "name": ...,
        "last_activity": ...,
    },
     {
        "id": ...,
        "status": ...,
        "platform": ...,
        "name": ...,
        "last_activity": ...,
    },
    ...
]
"""  
sstrong99 commented 3 weeks ago

It appears that this is already an option with to_json=True, although if this is documented somewhere i haven't found it.

ejseqera commented 2 weeks ago

Using to_json=True in tw.compute_envs("list") is probably the closest to what you are looking for to return a dict. We might potentially refactor this to avoid using kwargs, see draft implementation here: https://github.com/seqeralabs/seqera-kit/pull/146

We will make a note to document this option better once implemented.

sstrong99 commented 2 weeks ago

Thanks! it would be nice to maintain that sort of functionality for the python API if that refactor happens.