Skip to content

Fix Protobuf URLs#5373

Merged
scheibelp merged 3 commits intospack:developfrom
ax3l:fix-protobufUrls
Sep 25, 2017
Merged

Fix Protobuf URLs#5373
scheibelp merged 3 commits intospack:developfrom
ax3l:fix-protobufUrls

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Sep 15, 2017

GitHub releases with additional .tar.gz source archive uploads to their actual tag tend to return random selections of which archive shall be taken. Related to #5356

This fixes it for protobuf with a hack to prioritize GitHub Source Archives over additional release artifacts. The interesting observation is also, that the pick from the list_url is also not deterministic.

I would propose to rewrite lib/spack/spack/util/web to use for pages, links and versions an ordered dict to get at least determinism into the version url fetching.

Before (note the wrong pick in the 3.3.0 & 3.4.0 release!):

$ spack checksum protobuf
==> Found 10 versions of protobuf:

  3.4.1     https://github.com/google/protobuf/archive/v3.4.1.tar.gz
  3.4.0rc3  https://github.com/google/protobuf/archive/v3.4.0rc3.tar.gz
  3.4.0rc2  https://github.com/google/protobuf/archive/v3.4.0rc2.tar.gz
  3.4.0rc1  https://github.com/google/protobuf/archive/v3.4.0rc1.tar.gz
  3.4.0     https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-ruby-3.4.0.tar.gz
  3.3.2     https://github.com/google/protobuf/archive/v3.3.2.tar.gz
  3.3.1     https://github.com/google/protobuf/archive/v3.3.1.tar.gz
  3.3.0rc1  https://github.com/google/protobuf/archive/v3.3.0rc1.tar.gz
  3.3.0     https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-ruby-3.3.0.tar.gz
  3.2.1     https://github.com/google/protobuf/archive/v3.2.1.tar.gz

Now:

$ spack checksum protobuf
==> Found 10 versions of protobuf:
  
  3.4.1     https://github.com/google/protobuf/archive/v3.4.1.tar.gz
  3.4.0rc3  https://github.com/google/protobuf/archive/v3.4.0rc3.tar.gz
  3.4.0rc2  https://github.com/google/protobuf/archive/v3.4.0rc2.tar.gz
  3.4.0rc1  https://github.com/google/protobuf/archive/v3.4.0rc1.tar.gz
  3.4.0     https://github.com/google/protobuf/archive/v3.4.0.tar.gz
  3.3.2     https://github.com/google/protobuf/archive/v3.3.2.tar.gz
  3.3.1     https://github.com/google/protobuf/archive/v3.3.1.tar.gz
  3.3.0rc1  https://github.com/google/protobuf/archive/v3.3.0rc1.tar.gz
  3.3.0     https://github.com/google/protobuf/archive/v3.3.0.tar.gz
  3.2.1     https://github.com/google/protobuf/archive/v3.2.1.tar.gz

Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you disagree with the suggestions.

patch('pkgconfig.patch', when='@:3.3.2')

def fetch_remote_versions(self):
"""fix for https://github.com/LLNL/spack/issues/5356"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO a description of the issue would be good here vs. a link.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right, will do!
the idea of the link was just: in case we improve upon the situation generally, the link can be grep-ed and updated.

def fetch_remote_versions(self):
"""fix for https://github.com/LLNL/spack/issues/5356"""
return dict(map(lambda u:
(u, self.url_for_version(Version(u))),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constrains the function to checksum only existing versions in this package. IMO it would be better to call:

spack.util.web.find_versions_of_archive([], list_url...)

Or at least I think it will work if archive_urls is an empty list. Then this function should be able to automatically find new releases.

Copy link
Copy Markdown
Member Author

@ax3l ax3l Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for the idea, I tried to test that but it did not find version for me.
can you give me a more explicit example, please? I actually wanted to avoid the scraper in find_versions_of_archive since it is:

  • not deterministic
  • pics a random release if several are found for a version (which will randomly break the hash)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I think I managed, will push an update! :)

(u, self.url_for_version(Version(u))),
self.versions))

def url_for_version(self, version):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this strictly required if the fetch_remote_versions function is overridden? The definition in Package appears to do a direct replacement vs. searching for a releases/ directory.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since I do need that functionality in the member function above, and it's exactly what url_for_version would do I think it's useful to keep it in a separate call, no?

@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Sep 18, 2017

@scheibelp what do you think of the changes? :)

"""Ignore additional source artifacts uploaded with releases,
only keep known versions
fix for https://github.com/LLNL/spack/issues/5356"""
return dict(map(lambda u:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although flake is OK with this, IMO it could be more-clearly formatted:

return dict(map(
  lambda u: (u, self.url_for_version(u)),
  spack.util.web.find_versions_of_archive(
    self.all_urls, self.list_url, self.list_depth)
))

Other than that your changes LGTM. No need to fight flake though if it's hard to format it in a matter that flake accepts. I'll get another chance to check this in a few hours. If you think the formatting is fine let me know.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem, will adjust to your recommended line-breaking

@scheibelp
Copy link
Copy Markdown
Member

LGTM, I'll merge this when the tests pass. There seems to be a slowdown on travis at the moment, in particular with the mac builds, so I don't think this will happen today.

@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Sep 19, 2017

@scheibelp all tests passed but code coverage fails in one (I don't know why)

@scheibelp
Copy link
Copy Markdown
Member

Sorry I was looking over this again and I noticed the following conversation at #5373 (comment):

Is this strictly required if the fetch_remote_versions function is overridden? The definition in Package appears to do a direct replacement vs. searching for a releases/ directory.

since I do need that functionality in the member function above, and it's exactly what url_for_version would do I think it's useful to keep it in a separate call, no?

What I meant there was: I think your implementation of url_for_version is the same as the default implementation of Package.url_for_version, in particular because Package.url is https://github.com/google/protobuf/archive/v3.2.0.tar.gz. The substitution logic in the default Package.url_for_version should be smart enough to handle this. In other words, I think everything will work if you remove the definition of url_for_version in the Protobuf package.py

Does that make sense? Or do you feel it is clearer to still override Package.url_for_version?

@scheibelp
Copy link
Copy Markdown
Member

@ax3l BTW the test coverage is not an issue for me (and I think it's confused) but I do think url_for_version can just use the default provided in Package.

GitHub releases with additional `.tar.gz` source archive uploads to
their actual tag tend to return random selections of which archive
shall be taken.

This fixes it for protobuf with a rather deep hack.

Before:
```
$ spack checksum protobuf
==> Found 10 versions of protobuf:

  3.4.1     https://github.com/google/protobuf/archive/v3.4.1.tar.gz
  3.4.0rc3  https://github.com/google/protobuf/archive/v3.4.0rc3.tar.gz
  3.4.0rc2  https://github.com/google/protobuf/archive/v3.4.0rc2.tar.gz
  3.4.0rc1  https://github.com/google/protobuf/archive/v3.4.0rc1.tar.gz
  3.4.0     https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-ruby-3.4.0.tar.gz
  3.3.2     https://github.com/google/protobuf/archive/v3.3.2.tar.gz
  3.3.1     https://github.com/google/protobuf/archive/v3.3.1.tar.gz
  3.3.0rc1  https://github.com/google/protobuf/archive/v3.3.0rc1.tar.gz
  3.3.0     https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-ruby-3.3.0.tar.gz
  3.2.1     https://github.com/google/protobuf/archive/v3.2.1.tar.gz
```

Now:
```
$ spack checksum protobuf
==> Found 4 versions of protobuf:

  3.4.0  https://github.com/google/protobuf/archive/v3.4.0.tar.gz
  3.3.0  https://github.com/google/protobuf/archive/v3.3.0.tar.gz
  3.2.0  https://github.com/google/protobuf/archive/v3.2.0.tar.gz
  3.1.0  https://github.com/google/protobuf/archive/v3.1.0.tar.gz
  3.0.2  https://github.com/google/protobuf/archive/v3.0.2.tar.gz
```
Add review comments. Allows to automatically fetch new versions
again and still only keeps the original source of the tag instead
of chosing additional `.tar.gz` artifacts that come with the
release.
@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Sep 25, 2017

@scheibelp you are right, I do not need to overwrite the url_for_version anymore! removed it.

@scheibelp scheibelp merged commit 28dd6b3 into spack:develop Sep 25, 2017
@scheibelp
Copy link
Copy Markdown
Member

Thanks!

@ax3l ax3l deleted the fix-protobufUrls branch September 25, 2017 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants