Skip to content

Add full_hash and json index to buildcache#8451

Closed
scottwittenburg wants to merge 2 commits intospack:developfrom
scottwittenburg:buildcache-add-fullhash-and-yaml-index
Closed

Add full_hash and json index to buildcache#8451
scottwittenburg wants to merge 2 commits intospack:developfrom
scottwittenburg:buildcache-add-fullhash-and-yaml-index

Conversation

@scottwittenburg
Copy link
Copy Markdown
Contributor

No description provided.

@scottwittenburg
Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

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

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):
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 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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',
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.

I would just do this and the index by default. Having them there should not hurt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

@scottwittenburg scottwittenburg force-pushed the buildcache-add-fullhash-and-yaml-index branch 2 times, most recently from 340b220 to 6caac36 Compare July 10, 2018 17:36
@scottwittenburg scottwittenburg force-pushed the buildcache-add-fullhash-and-yaml-index branch from 6caac36 to bc25fa1 Compare August 8, 2018 22:47
@scottwittenburg scottwittenburg changed the title Add full_hash and yaml index to buildcache Add full_hash and json index to buildcache Aug 8, 2018
@scottwittenburg scottwittenburg force-pushed the buildcache-add-fullhash-and-yaml-index branch 2 times, most recently from 03c9a4a to aab717c Compare August 9, 2018 16:36
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

@tgamblin Except for some issue I ran into (described in #8929), this is working and seems pretty close. I have addressed the issues you brough up, and I think it's time for a second look whenever you get a chance. Thanks!

@scottwittenburg
Copy link
Copy Markdown
Contributor Author

fyi @zackgalbreath

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

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

@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)
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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll do it.

buildinfo['relative_prefix'] = os.path.relpath(
spec.prefix, spack.store.layout.root)
spec_dict['buildinfo'] = buildinfo
spec.concretize()
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 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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',
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.

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'):
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.

why was this needed? Are you seeing specs without it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

@scottwittenburg scottwittenburg force-pushed the buildcache-add-fullhash-and-yaml-index branch 2 times, most recently from 2cef5db to 2d1eb61 Compare August 23, 2018 15:35
Also create an index.json in addition to the normal index.html file.
@scottwittenburg scottwittenburg force-pushed the buildcache-add-fullhash-and-yaml-index branch from 2d1eb61 to 1eea39c Compare August 23, 2018 17:06
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

Closing in favor of #10274

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.

3 participants