Skip to content

Commit

Permalink
revert the eager wheel_name inference to fix caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Nov 22, 2023
1 parent 3d71ae9 commit 15afd56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
8 changes: 7 additions & 1 deletion metaflow/plugins/pypi/conda_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,17 @@ def _datastore_url(url, local_path):
# Cache only those packages that manifest is unaware of
local_packages.pop(package["url"], None)
else:
pkg_path = urlparse(package["url"]).path
# TODO: Match up with CONDA_DATASTORE_ROOT so that cache
# gets invalidated when DATASTORE is moved.
# We might have built the wheel during resolving,
# in which case we need to pull the actual package name from the local path
if package.get("require_build", False):
local_path = local_packages[package["url"]]["local_path"]
pkg_path = local_path
package["path"] = _datastore_url(
package["url"],
package.get("wheel_name", urlparse(package["url"]).path),
pkg_path,
)
dirty.add(id_)

Expand Down
17 changes: 4 additions & 13 deletions metaflow/plugins/pypi/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,8 @@ def solve(self, id_, packages, python, platform):
def _format_item(item):
dl_info = item["download_info"]
res = {k: v for k, v in dl_info.items() if k in ["url"]}
# Infer wheel name from url
res["wheel_name"] = res["url"].split("/")[-1]
res["require_build"] = False
# If wheel name is not a wheel, we need to build the target. Construct a wheel name and add a build flag
if not res["wheel_name"].endswith(".whl"):
res["wheel_name"] = "{name}-{version}.whl".format(
name=item["metadata"]["name"],
version=item["metadata"]["version"],
)
res["require_build"] = True
# If source url is not a wheel, we need to build the target. Add a build flag.
res["require_build"] = not res["url"].endswith(".whl")

# reconstruct the VCS url and pin to current commit_id
# so using @branch as a version acts somewhat as expected.
Expand Down Expand Up @@ -191,7 +183,6 @@ def download(self, id_, packages, python, platform):
"download",
"--no-deps",
"--no-index",
"--no-build-isolation", # required when using --no-index for setuptools to be found.
"--progress-bar=off",
# if packages are present in Pip cache, this will be a local copy
"--dest=%s/.pip/wheels" % prefix,
Expand All @@ -210,7 +201,7 @@ def download(self, id_, packages, python, platform):
cmd.append(package["url"])
# record the url-to-path mapping fo wheels in metadata file.
metadata[package["url"]] = "{prefix}/.pip/wheels/{wheel}".format(
prefix=prefix, wheel=package["wheel_name"]
prefix=prefix, wheel=package["url"].split("/")[-1]
)
self._call(prefix, cmd)
# write the url to wheel mappings in a magic location
Expand Down Expand Up @@ -243,7 +234,7 @@ def create(self, id_, packages, python, platform):

def metadata(self, id_, packages, python, platform):
# read the url to wheel mappings from a magic location.
# Combine the metadata and build_metadata files, allowing build_metadata mappings to override.
# Combine the metadata and build_metadata files (these should be disjoint sets).
prefix = self.micromamba.path_to_environment(id_)
metadata_file = METADATA_FILE.format(prefix=prefix)
build_metadata_file = BUILD_METADATA_FILE.format(prefix=prefix)
Expand Down

0 comments on commit 15afd56

Please sign in to comment.