-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
JSON Schema proposal: All inputs should appear under the input
key
#996
Comments
I thought about trying to do this, but my current reaction to "would this benefit you and/or your track" is "meh" since I don't maintain any track that uses generators, and the humans reading the JSON files seem to have no trouble understanding which keys represent the inputs. But hey, it's here if people want it, and maybe it'll be good to have. |
Having |
Absolutely! It would make processing the JSON simpler and less error-prone.
Same here. |
I would be happy about consilidating those keys under |
I see a comment https://github.com/exercism/problem-specifications/blob/master/canonical-schema.json#L6-L10 in the schema file that explains why I allege that since the vast majority of our specifications are example-based that we can proceed with So I think all we will ask is that this schema does not prevent a future expansion where we might add the ability to encode a property-based test. I think such an expansion can be added in another key that is not |
If we take action on this (I would wait until a week has passed since the filing of the proposal), plan what to do with the version. Assume that an exercise that is converted to the new schema is currently versioned x.y.z.
Adopting a different version schema simultaneously allows us to take the interesting shortcut of "an exercise is converted to the new My preferences are as I noted earlier. Single-component version > No version at all > Two-component version with CI enforcement that some version component changes ≈ Two-component version without CI enforcement > current version scheme. |
I think that for exercises who have their The proposals to reduce the version number to a two- or one-component number discard clarity for simplicity. I can't deny that they're simpler, but I believe that knowledge of standard three-component semantic versioning is fairly widespread in the programming community at this point. The proposal to abandon versioning in favor of git SHAs or other schemes have the drawback that it becomes harder for humans to tell what's going on at a glance, and impossible for them to estimate the difference between two files at a glance. |
Can we try and keep the versioning discussions in #938 so they will be more easily discoverable to future generations. |
Well, to my surprise, in 24 * 7 hours there were no objection and there was also nonzero support. I suppose we can call it open season to convert JSON files to this, then. #998 will be able to tell us which exercises were converted or not. I would make a big checklist like #625 did but since my allotted time is up now, I can't. |
I'm late here, but these are all the
|
exercism#996 Updated the schema for canonical data. So I am updating the book-store exercise's json to reflect the change.
This makes some progress on the concerns listed in #336 which were:
In fact, having an The remaining questions to resolve would probably be:
This proposal deliberately chose not to solve that problem because it chooses to take a small step at a time. If you were to predict that I will put forward a proposal to solve that problem, I advise you that that is an extremely unwise prediction to make. |
Everyone is reminded that, when submitting a PR that purports to move inputs to the |
Great work @petertseng! |
Since this proposal was accepted and is now being checked by CI, I believe it's safe to close the issue. Tracking of progress is done by counting the number of USE_OLD_SCHEMA files. even though it's a policy there's no need to keep it open since policies can be found with https://github.com/exercism/problem-specifications/issues?utf8=%E2%9C%93&q=label%3Apolicy |
Note that in react (#1130) and circular-buffer (#1186) to accommodate the schema (which requires If there is desire and demand for it, consider allowing |
grains 1.1.0 As proposed and accepted in #996 ```ruby have_input = false ARGF.each_line { |l| if l.include?('version') ver = l.split(?")[3] ver_components = ver.split(?.).map(&:to_i) ver_components[1] += 1 ver_components[2] = 0 l[ver] = ver_components.join(?.) end have_input &&= !l.include?('"description"') first_non_space = l.index(/\S/) if l.include?('"input"') have_input = true input = l.split(?:).last.to_i puts ' ' * first_non_space + '"input": {' puts ' ' * first_non_space + ' "square": ' + input.to_s puts ' ' * first_non_space + '},' next end puts ' ' * first_non_space + '"input": {},' if l.include?('"expected"') && !have_input puts l } ```
My advice to the person who will resolve this question: You will need to be able to account for language differences. Take https://github.com/exercism/problem-specifications/blob/master/exercises/accumulate/description.md for example. This is the higher-order function
The solution to this problem will need to take into account the possibility that different languages have different conventions. Whoops, I just typed this up and realized it's already been said before. #336 (comment). I'm sorry that I failed to add anything new to the discussion. |
In our schema, we know that
description
,expected
, andproperty
are fixed, but the inputs to each test case depend on the problem!That means we can't know ahead of time what key(s) constitute the inputs; we have to examine the JSON in order to do so.
According to those test generators listed at exercism/discussions#155 the current solutions to this problem take on one of two forms:
description
,expected
,property
, orcomments
. That key (or those keys) must be the input, by process of elimination.Well, what if we could do better?
Let's look at https://github.com/exercism/problem-specifications/blob/master/exercises/change/canonical-data.json where each case has two inputs:
coins
andtarget
. Let's say that instead a case looks like:As you can see, the key
input
contains an object whose keys and values represent the inputs.And what about https://github.com/exercism/problem-specifications/blob/master/exercises/leap/canonical-data.json where each case has only one input? One might consider two possible ways to do this:
The first way is actually how the JSON is already: The key
input
contains a scalar, the one and only input.The second way we might consider is that it will also be an object, for consistency. So then:
One could consider making that a one-liner:
"input": {"year": 2015}
) if vertical space savings are desired.This has the advantage of consistency, of course:
input
always contains an object, but the file also becomes more verbose.Were one of the two forms of this proposal to be implemented, would this benefit you and/or your track? Would it instead cause harm?
Alternative proposals to solve the problem of "we don't know the names of the keys that hold the input(s) ahead of time"?
The text was updated successfully, but these errors were encountered: