Improve readability of lockfiles#58
Conversation
andrius-puksta-sensmetry
left a comment
There was a problem hiding this comment.
Probably should also have a test for serialization round-trip.
I was thinking about that but wasn't sure how to best implement it. It doesn't seem to be a good fit for a unit test, since a round-trip isn't a unit of work. Not sure it's a good integration test either since the deserialization isn't really part of our library interface. I've been thinking about setting up some Property based testing for Sysand, and I think this would be the best fit for round-trip testing. Would have to be its own Issue though. But maybe I'm just overthinking things. |
|
There's something wonky with 'Python / Linux' jobs. First one stalled waiting for some Header, but seem to work when manually restarted it. I'll try the same with the others. |
Yes, it seems to be a good fit. Until that is done, we should have a few simple tests for this. Unit tests are best for it, because even though round-trip tests too much functionality at once for a unit test, at least the code being tested is completely self-contained and thus easy to write unit tests for. |
It's a network timeout. Happens sometimes to all jobs. |
|
Could we use a name for |
I'm confused by how this would be used during validation and resolution. Under what circumstances (where you would not also have access to the full .project.json and .meta.json contents) would it be used? |
I considered this at first but decided against it. Mostly because I not sure the average user will care about the content of |
Well if you pull a git repo with with a lockfile and do sync your not going to have the manifests for all the dependencies immediately at hand. I think it seems like good practice to do a quick sanity check on the lockfile before you start downloading stuff. As far as I know the dependency solver doesn't take name collisions in the exports into account, but I feel like that would be a reasonable thing to do since, from what I can tell, KerML/SysML has no way of handling that at all. One of the imports will just get overridden by the other. Sure we don't absolutely need to include exports, but it seemed fitting since for the most part these are the actual package names and it's the names the user will interact with inside of KerML/SysML. |
So the general point would be that you propose to be able to validate the lock file early (in certain circumstances). Early in the sense that you do not have all the mentioned projects ready in local environments yet. It's not clear to me under what circumstances this would be useful. That being said, from a human readability standpoint I think you make a good point that to many actual users, top level names exported by the project may actually be more recognisable than the project name 👍 |
Fair enough. |
|
I'm really happy with the above as the default generation, but I'd like to have Strictly mandatory:
Recommended (meaning
Optional (meaning
I don't expect to have round-tripping work for the optional ones, so it can simply be implemented as not giving an "unexpected field" error in case they're present. This can even be done by simply allowing arbitrary additional fields, potentially with a warning message like "ignoring field X". In particular, there is no need to implement any options to include this optional information during lock file generation. This makes the format more backward compatible in case we want to introduce changes later (even once we're out of The main reason for making recommended fields optional is to force us to not accidentally depend on them being present when they're purely informative. |
c14930f to
aa98760
Compare
This is the default behaviour of |
Considering the amount of other ad-hoc validation we're doing, wouldn't it make sense to also check that the fields are correct? |
Maybe? We could potentially emit warnings for additional fields. |
I don't feel strongly either way, but might save us some headache in case people mess with their lockfiles. |
d83e736 to
dd87484
Compare
andrius-puksta-sensmetry
left a comment
There was a problem hiding this comment.
LTGM, aside from a few nits above.
tilowiklundSensmetry
left a comment
There was a problem hiding this comment.
I think we've converged as much as we will in the short term. Look good, let's merge this.
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
Signed-off-by: victor.linroth.sensmetry <victor.linroth@sensmetry.com>
2b3b6f7 to
68ba0b9
Compare
The lockfile was renamed in #58 Signed-off-by: Simonas Draukšas <simonas.drauksas@sensmetry.com>
* chore(docs): Fix case of 'SysandLock.toml' to 'sysand-lock.toml' The lockfile was renamed in #58 * chore(docs): Change file paths to generic project structure Updated file paths in the tutorial to use a generic project path. --------- Signed-off-by: Simonas Draukšas <simonas.drauksas@sensmetry.com>
Summary
The current lockfile structure is difficult to inspect manually and can potentially
produce noisy diffs in version control. These updates aim to make the lockfile easier
to understand and audit.
toml_editfor manual serializing, allowing inline tables and bracketed(multiline) lists.
infoandmetaentries are too deeply nestedto be displayed well inline so they were replaced by specific entries for
name,version,exports* andusages.automatically generated and not intended to be edited manually. (To provide
extra clarity for the less technical users.)
readable diffs in version control).
checksumgoes last since you're unlikely to want to visually inspect that.iristoidentifiers.*
exportsare the top level symbols exported by the project and are taken from theindexin.meta.json. It was included because in a way these are the true "names"of a project as seen from KerML/SysML, and can be part of lockfile validation (and
maybe also dependency solving at some point).
Example
A project now fits under a single entry like e.g.
Motivation
Lockfile project entries have been evaluated for inclusion and ordering based on
the following points:
Readability Relates to the users experience manually inspecting the lockfile
directly, or looking at diffs from version control.
Validation There are two stages when validation can considered:
after lockfile generation and when loading a lockfile for syncing. Currently the
lockfile generation process is not that complex, but as it gets more complex it
can be good to have a validation step at the end to catch bugs early. An externally
loaded lockfile has no guarantees of validity and should be checked in order to
"fail fast" and hopefully produce better error messages. When loading a lockfile
it is not always the case that all relevant project files will be immediately
available so it can be advantageous if (some) validation can be performed only with
the contents of the lockfile. Validation can also be used as part of testing.
Reproducibility The ability to ensure that the same model is loaded for each
user. Note that this may not always be desired, like when developing multiple
projects in conjunction. For this reason
checksumshould probably be made optional,but that change can be added at a later time.
nameand as a potential reference in error messages.
versionsatisfied.
exportsas and as such are the real "names" from a KerML/SysML perspective.
in a standard compliant way, we should make sure there is no overlap between
projects.
identifiers(so not required for current project).
usagesin dependencies. In particular shows if a version update changes dependencies.
sourceschecksumlockfile was generated.
Additional changes
Basic validation functionality has been added to better illustrate it's relevance
in relation to project entries.
A preliminary check of the lockfile has been introduced that only depends on it being valid TOML. Here the lockfile version is checked and there are warnings issued if unknown fields are encountered in the lockfile. This is an effort to make potential errors easier to debug.
To signify the changes the lockfile name has also been changed to
sysand-lock.tomlandlock_versionhas been bumped to "0.2".