예제 #1
0
    def test_download_file(self):
        store = PolyaxonStore(
            client=RunClient(owner="test", project="test", run_uuid="uid"))
        with patch("polyaxon.stores.polyaxon_store.PolyaxonStore.download"
                   ) as mock_call:
            result = store.download_file(url="url", path="test/path")

        assert result == "{}/uid/test/path".format(
            settings.CLIENT_CONFIG.archive_root)
        assert mock_call.call_count == 1
        assert mock_call.call_args_list[0][1] == {
            "filename": result,
            "params": {
                "path": "test/path"
            },
            "url": "url",
        }

        with patch("polyaxon.stores.polyaxon_store.PolyaxonStore.download"
                   ) as mock_call:
            result = store.download_file(url="url",
                                         path="test/path",
                                         untar=False)

        assert result == "{}/uid/test/path.tar.gz".format(
            settings.CLIENT_CONFIG.archive_root)
        assert mock_call.call_count == 1
        assert mock_call.call_args_list[0][1] == {
            "filename": result,
            "untar": False,
            "params": {
                "path": "test/path"
            },
            "url": "url",
        }

        with patch("polyaxon.stores.polyaxon_store.PolyaxonStore.download"
                   ) as mock_call:
            result = store.download_file(url="url",
                                         path="test/path",
                                         untar=True)

        assert result == "{}/uid/test/path".format(
            settings.CLIENT_CONFIG.archive_root)
        assert mock_call.call_count == 1
        assert mock_call.call_args_list[0][1] == {
            "filename": "{}.tar.gz".format(result),
            "untar": True,
            "params": {
                "path": "test/path"
            },
            "url": "url",
        }
예제 #2
0
파일: run.py 프로젝트: smilee/polyaxon
    def download_artifact(self,
                          path: str,
                          force: bool = False,
                          path_to: str = None):
        """Downloads a single run artifact.

        Args:
            path: str, the relative path of the artifact to return.
            path_to: str, optional, path to download to.
            force: bool, force reload the artifact.

        Returns:
            str
        """
        url = PolyaxonStore.URL.format(
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
            subpath="artifact",
        )
        url = "{host}/{url}".format(host=clean_host(self.client.config.host),
                                    url=url)
        if force:
            url = "{}?force=true".format(url)

        return PolyaxonStore(client=self).download_file(url=url,
                                                        path=path,
                                                        path_to=path_to)
예제 #3
0
    def download_artifacts(
        self,
        path: str = "",
        path_to: str = None,
        untar: bool = True,
        delete_tar: bool = True,
        extract_path: str = None,
    ):
        """Downloads a list of run artifacts.

        Args:
            path: str, the relative path of the artifact to return.
            path_to: str, optional, path to download to.
            untar: bool, optional, default: true.
            delete_tar: bool, optional, default: true.
            extract_path: str, optional.

        Returns:
            str.
        """
        url = "{host}/streams/v1/{namespace}/{owner}/{project}/runs/{uuid}/artifacts".format(
            host=clean_host(self.client.config.host),
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
        )

        return PolyaxonStore(client=self).download_file(
            url=url,
            path=path,
            untar=untar,
            delete_tar=delete_tar,
            extract_path=extract_path,
        )
예제 #4
0
파일: run.py 프로젝트: savvihub/polyaxon
    def download_artifact(self, path: str):
        url = "{host}/streams/v1/{namespace}/{owner}/{project}/runs/{uuid}/artifact".format(
            host=self.client.config.host,
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
        )

        return PolyaxonStore(client=self).download_file(url=url, path=path)
예제 #5
0
    def download_artifact(self, path: str):
        """Downloads run artifact.

        Args:
            path: str, the relative path of the artifact to return.

        Returns:
            str
        """
        url = "{host}/streams/v1/{namespace}/{owner}/{project}/runs/{uuid}/artifact".format(
            host=self.client.config.host,
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
        )

        return PolyaxonStore(client=self).download_file(url=url, path=path)
예제 #6
0
파일: run.py 프로젝트: zhaohb/polyaxon
    def download_artifact(self, path: str, force: bool = False):
        """Downloads run artifact.

        Args:
            path: str, the relative path of the artifact to return.
            force: bool, force reload the artifact.

        Returns:
            str
        """
        url = "{host}/streams/v1/{namespace}/{owner}/{project}/runs/{uuid}/artifact".format(
            host=clean_host(self.client.config.host),
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
        )
        if force:
            url = "{}?force=true".format(url)

        return PolyaxonStore(client=self).download_file(url=url, path=path, force=force)
예제 #7
0
파일: run.py 프로젝트: smilee/polyaxon
    def download_artifacts(
        self,
        path: str = "",
        path_to: str = None,
        untar: bool = True,
        delete_tar: bool = True,
        extract_path: str = None,
    ):
        """Downloads a subpath containing multiple run artifacts.

        Args:
            path: str, the relative path of the artifact to return.
            path_to: str, optional, path to download to.
            untar: bool, optional, default: true.
            delete_tar: bool, optional, default: true.
            extract_path: str, optional.

        Returns:
            str.
        """
        url = PolyaxonStore.URL.format(
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
            subpath="artifacts",
        )
        url = "{host}/{url}".format(host=clean_host(self.client.config.host),
                                    url=url)

        return PolyaxonStore(client=self).download_file(
            url=url,
            path=path,
            untar=untar,
            path_to=path_to,
            delete_tar=delete_tar and untar,
            extract_path=extract_path,
        )
예제 #8
0
파일: run.py 프로젝트: savvihub/polyaxon
    def download_artifacts(
        self,
        path: str = "",
        path_to: str = None,
        untar: bool = True,
        delete_tar: bool = True,
        extract_path: str = None,
    ):
        url = "{host}/streams/v1/{namespace}/{owner}/{project}/runs/{uuid}/artifacts".format(
            host=self.client.config.host,
            namespace=self.namespace,
            owner=self.owner,
            project=self.project,
            uuid=self.run_uuid,
        )

        return PolyaxonStore(client=self).download_file(
            url=url,
            path=path,
            untar=untar,
            delete_tar=delete_tar,
            extract_path=extract_path,
        )