Add full_hash and json index to buildcache#8451
Add full_hash and json index to buildcache#8451scottwittenburg wants to merge 2 commits intospack:developfrom
Conversation
|
I have made these changes to support the work I'm doing in #8444, but the topic may need adjustments to make sure its sensible for everyone else. Per our discussion this morning @tgamblin @opadron @aashish24 @bryonbean |
tgamblin
left a comment
There was a problem hiding this comment.
This looks good, but I think the file should be json, and the index shouldn't be optional.
| f.close() | ||
|
|
||
|
|
||
| def generate_yaml_index(pathList, outputPath): |
There was a problem hiding this comment.
this is a good start but likely needs a schema like the other YAML files. Also, I think json is actually better for things to be read by computers (not people). Does your checkbinaries command actually look at this YAML file or just the HTML?
There was a problem hiding this comment.
I'll change it to json, do we already have json schemas somewhere in the repo? Once I have it change to json, I'll update the check-binaries code to read that instead.
lib/spack/spack/cmd/buildcache.py
Outdated
| create.add_argument('-d', '--directory', metavar='directory', | ||
| type=str, default='.', | ||
| help="directory in which to save the tarballs.") | ||
| create.add_argument('-i', '--include_full_hash', action='store_true', |
There was a problem hiding this comment.
I would just do this and the index by default. Having them there should not hurt.
There was a problem hiding this comment.
Sounds good.
340b220 to
6caac36
Compare
6caac36 to
bc25fa1
Compare
03c9a4a to
aab717c
Compare
|
fyi @zackgalbreath |
tgamblin
left a comment
There was a problem hiding this comment.
@scottwittenburg: LGTM mostly! I have some minor requests and then I'm curious why you're seeing specs with patches but without _patches_in_order_of_appearance. Are they concrete?
| os.remove(p) | ||
|
|
||
| generate_html_index(path_list, index_html_path) | ||
| generate_json_index(path_list, index_json_path) |
There was a problem hiding this comment.
instead of removing then generating in-place, can you generate to a .index.json.tmp file, and then move that on top of index.json? That way the change is atomic and you don't risk failing with missing or partial indices. The local name/suffix (as opposed to tmp or something) guarantees it's on the same filesystem, so a move will be atomic.
There was a problem hiding this comment.
Sounds good, I'll do it.
| buildinfo['relative_prefix'] = os.path.relpath( | ||
| spec.prefix, spack.store.layout.root) | ||
| spec_dict['buildinfo'] = buildinfo | ||
| spec.concretize() |
There was a problem hiding this comment.
Is this needed? I would assume that any spec passed to build_tarball is concrete -- probably needs an assert or at least a check and a raised ValueError -- or are you relying on the spec to be concretized here?
There was a problem hiding this comment.
It seemed the spec was not concrete here, and then computing the full_hash in the next line would throw an exception. As this was the last possible moment before the spec information was written out to the .spec.yaml, I assumed that if it hadn't been done by this point, then I should do it myself.
lib/spack/spack/cmd/buildcache.py
Outdated
| create.add_argument('-d', '--directory', metavar='directory', | ||
| type=str, default='.', | ||
| help="directory in which to save the tarballs.") | ||
| create.add_argument('-s', '--skip_rebuild_index', action='store_true', |
There was a problem hiding this comment.
Can this be: --no-rebuild-index and have no short argument? Seems like it would be used infrequently or only in scripts (where you want readability), but maybe I'm underestimating. Also I dunno why allow_root has an underscore -- but nearly all the other commands in Spack use -.
|
|
||
| variants_patches = self.variants['patches'] | ||
|
|
||
| if not hasattr(variants_patches, '_patches_in_order_of_appearance'): |
There was a problem hiding this comment.
why was this needed? Are you seeing specs without it?
There was a problem hiding this comment.
Yes, sometimes I was getting an exception without this (I believe it was when I was testing creating a buildcache entry after I made the change which added the full_hash). Perhaps it was just something about the state of my repo and local configs at the time? At any rate, sometimes variants_patches did not have a _patches_in_order_of_appearance attribute, so I just guarded it.
There was a problem hiding this comment.
@tgamblin I found some notes where I had documented (kind of) the issue that was happening here. It happened when creating a buildcache entry:
==> creating binary cache file for package [email protected]%[email protected]+dbm~optimizations patches=123082ab3483ded78e86d7c809e98a804b3465b4683c96bd79a2fd799f572244 +pic+pythoncmd+shared~tk~ucs4 arch=linux-ubuntu16.04-x86_64
==> Error: 'MultiValuedVariant' object has no attribute '_patches_in_order_of_appearance'
I have checked out the current develop branch, and tried creating a spec for python similar to the one shown above, then concretizing and full_hash-ing it, but I could not reproduce the issue.
I wonder if the thing to do is to remove the change from my PR until such time as I encounter the issue again? Let me know what you think.
2cef5db to
2d1eb61
Compare
Also create an index.json in addition to the normal index.html file.
2d1eb61 to
1eea39c
Compare
|
Closing in favor of #10274 |
No description provided.