Example #1
0
    def _resolve_version(self, spec: AssetSpec) -> None:
        local_versions = self._list_local_versions(spec)
        logger.debug("Local versions", local_versions=local_versions)

        if spec.is_version_complete():
            return

        remote_versions = []
        if self.storage_provider:
            remote_versions = self.storage_provider.get_versions_info(
                spec.name)
            logger.debug("Fetched remote versions",
                         remote_versions=remote_versions)

        all_versions = spec.sort_versions(version_list=set(local_versions +
                                                           remote_versions))

        if not all_versions:
            if not spec.version:
                logger.debug("Asset has no version information")
                # no version is specified and none exist
                # in this case, the asset spec is likely a relative or absolute
                # path to a file/directory
                return None

            raise errors.LocalAssetDoesNotExistError(
                name=spec.name,
                version=spec.version,
                local_versions=local_versions,
            )

        # at least one version info is missing, update to the latest
        spec.set_latest_version(all_versions)
Example #2
0
def test_asset_spec_set_latest_version():
    spec = AssetSpec(name="a", versioning="simple_date")
    spec.set_latest_version(["2021-11-15T17-31-06Z", "2021-11-14T18-00-00Z"])
    assert spec.version == "2021-11-15T17-31-06Z"

    spec = AssetSpec(name="a",
                     version="2021-11-14T18-00-00Z",
                     versioning="simple_date")
    spec.set_latest_version(["2021-11-15T17-31-06Z", "2021-11-14T18-00-00Z"])
    assert spec.version == "2021-11-15T17-31-06Z"
Example #3
0
def test_asset_spec_set_latest_version():
    spec = AssetSpec(name="a", versioning="major_minor")
    spec.set_latest_version(["3", "2.1", "1.3"])
    assert spec.version == "3"

    spec = AssetSpec(name="a", version="2", versioning="major_minor")
    spec.set_latest_version(["3", "2.1", "2.0", "1.3"])
    assert spec.version == "2.1"

    spec = AssetSpec(name="a", version="1.1", versioning="major_minor")
    spec.set_latest_version(["3", "2.1", "2.0", "1.3"])
    assert spec.version == "1.3"