Skip to content

Any suggected way to use dvc from python? #3278

@byaka

Description

@byaka

We want to use dvc commands right from our software.

As i see dvc dont have stable api for this.

what way u suggest?

i find this and here they use it like

from setuptools import setup
from setuptools.command.build_py import build_py
from dvc.main import main


class FetchError(Exception):
    pass


class AssetFetcher(build_py):

    def run(self):
        print('Start pulling dvc asset')
        
        ret = main(['pull', 'train.dvc'])
        if ret != 0:
            msg = 'DVC returned error code {} while pulling assets'
            raise FetchError(msg.format(ret))
        
        print('Asset pulled successfully !')
        build_py.run(self)


setup(
    name='vat_detection',
    # and many other arguments ...
    cmdclass={'build_py': AssetFetcher}
)

Is this way ok or it can breaks on new versions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responsewe are waiting for your reply, please respond! :)questionI have a question?

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions