Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store the realisations as JSON in the binary cache #4333

Merged

Conversation

thufschmitt
Copy link
Member

@thufschmitt thufschmitt commented Dec 8, 2020

Fix #4332

@thufschmitt thufschmitt added the ca-derivations Derivations with content addressed outputs label Dec 8, 2020
@Ericson2314
Copy link
Member

@regnat I think the depends and the target branch clash, which is why dpulls is complaining?

@thufschmitt
Copy link
Member Author

@regnat I think the depends and the target branch clash, which is why dpulls is complaining?

Nah, unless I misunderstood something dpulls only complains because the dependency isn't merged. Should be green once we merge it

@Ericson2314
Copy link
Member

@regnat but the PR is into ca/properly-store-outputs, not master. It shouldn't matter whether or not ca/properly-store-outputs is merged into anything else because that doesn't effect whether things can be merged into it, and this pull request doesn't depend on anything?

@thufschmitt
Copy link
Member Author

thufschmitt commented Dec 10, 2020

@regnat but the PR is into ca/properly-store-outputs, not master. It shouldn't matter whether or not ca/properly-store-outputs is merged into anything else because that doesn't effect whether things can be merged into it, and this pull request doesn't depend on anything?

Oh yes, I see what you mean. Well the thing is that something (either dpulls or github itself) automatically changes the target branch to master if the current one gets deleted. So the workflow I use when branch2 depends on branch1 is

  1. Open a PR #1 for branch1 against master
  2. Open a PR #2 for branch2 against branch1, depending on #1

Then both PRs have a nice diff (showing only the incremental changes from the previous one) and only #1 can be merged in a first time. Once #1 is merged, #2 gets re-targeted against master and dpulls unblocks it, so we can merge it.

TL;DR: This is on purpose to ensure both a clean diff and a proper ordering of the PRs

@Ericson2314
Copy link
Member

Oh wow, how odd.

Well, I feel like we might as well actually merge this into the other one now that it's finished? (and it doesn't add more complexity.)

@thufschmitt thufschmitt force-pushed the ca/json-realisations-in-binary-caches branch from 6182254 to eee5270 Compare December 11, 2020 20:04
@thufschmitt thufschmitt merged commit 8914e01 into ca/properly-store-outputs Dec 11, 2020
@thufschmitt thufschmitt deleted the ca/json-realisations-in-binary-caches branch December 11, 2020 20:05
} else {
return std::nullopt;
}
}

void BinaryCacheStore::registerDrvOutput(const Realisation& info) {
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
upsertFile(filePath, info.to_string(), "text/x-nix-derivertopath");
upsertFile(filePath, info.toJSON(), "application/json");
Copy link
Member

Choose a reason for hiding this comment

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

is the out of toJSON reproducible?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question… I guess the answer is “no, but we don't really care here”:

  • No because:
    1. It probably won't be reproducible across Nix versions because we might want to add new fields or extend existing fields (like we already occasionally do for the narinfo files)
    2. nlohmann::json (the library we're using behind the scenes to convert to json) doesn't explicitely guarantees that its output is reproducible between versions − although it seems to hold in practice. I've asked about it though because it could be needed in other places
  • But we don't care because these only have to be semantically equivalent (we never try to content-address them or whatever, and we want to give us the possibility of extending their format in the future anyways)

Copy link
Member

Choose a reason for hiding this comment

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

If we start using more JSON outputs, it would be nice if the fields were alphabetically sorted by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's just that, it's already the case − and even if there's no guaranty that the default won't change, that bit of the library is pluggable − so I'm not too worried.

The bits that might change is stuff like the representation of numbers (1000 vs 1E3 for example). That bit is hardcoded and the author didn't give any formal guaranty that it wouldn't change in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ca-derivations Derivations with content addressed outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants