Repository navigation
Offer method collections to download and load in one step - #781
Merged
Merged
Conversation
Some exporters pad every line of a SimaPro method file to the widest row, so a section marker reads `Impact category;;;;;` and a blank line `;;;;;`. The reader compared whole lines, found no section, and loaded the file with no category while reporting success. A line is now read without its trailing separators, which also keeps them out of the method's name and of the normalization-weighting set's name. A method file that yields no impact category is refused instead of loading empty.
A collection whose files partly failed logged only their number, so a file refused beside others that load never said which one or why.
An engine now carries a catalogue of method collections it can fetch itself: Environmental Footprint 3.1 and the expert, midpoint and footprint versions of IMPACT World+ 2.2.1. One call lists them with their publisher, licence, size and whether they are already there; another downloads one, keeps it only when its size and SHA-256 match the catalogue, stores it as an upload and loads it. The download follows no redirect, stops one byte past the stated size and says who asks, since some file servers refuse a request that does not. Wire revision 102; pyvolca gains available_method_collections() and install_method_collection(name).
…dress with its reason A download whose body stalls now ends after a minute of silence instead of holding the request open. An address the HTTP library cannot parse is caught with the other download failures. The test of the catalogue now requires the lowercase SHA-256 the engine compares against, and the changelog names the data version that carries the catalogue.
Main took revision 102 for the basis of a score on its contributions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #780, which reads the padded method files the IMPACT World+ collections come in. Retarget to
mainonce #780 is merged.Problem
To score with a method collection the engine does not ship, a user has to find the publisher's file, download it, then upload it. Nothing tells them which collections are known to load, and nothing checks that the file they found is the one expected.
Solution
The engine carries a catalogue,
data/method-catalog.toml, of collections it can fetch itself: Environmental Footprint 3.1, and the expert, midpoint and footprint versions of IMPACT World+ 2.2.1. Each entry states the publisher, version, licence (when the publisher states one), the page to cite, the file's https address, its size and its SHA-256.GET /api/v1/method-collections/availablelists the catalogue, each entry saying whether the engine already knows a collection of that name.POST /api/v1/method-collections/available/{name}/installdownloads the file, keeps it only when its size and SHA-256 match, stores it as an upload of that name and loads it.The download follows no redirect, stops one byte past the stated size, gives up after a minute without data, and sends a
User-Agent: one of the file servers refuses requests without one.Answers: 403 on a read-only engine, 404 for a name not in the catalogue, 409 for a name already known, 413 when the file is above the plan's upload limit, 502 when the server cannot be reached or answers with an error status, 422 when the file received is not the one expected.
Wire revision 103. pyvolca gains
available_method_collections()andinstall_method_collection(name).Remarks
data/VERSIONmoves.http-client-tls, listed inTHIRD_PARTY_LICENSES.md. No method file is shipped with the engine, so none is listed there.How to test
Done on a local engine: the four collections installed and loaded (Environmental Footprint 3.1 with 25 categories; IMPACT World+ Expert, Midpoint and Footprint with 36, 21 and 6). A second install answered 409; an unknown name, 404. From the REPL,
fetchEntryrefused a file of the wrong size, a file with a different SHA-256, a server answering 410 and an address it cannot parse, each with its reason.