-
Notifications
You must be signed in to change notification settings - Fork 17
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
cli: implement diff
command
#82
Conversation
if len(lines) != 0 { | ||
equalSpecification = false | ||
utils.PrintColorable( | ||
fmt.Sprintf("%s Differences in workflow %s\n", leadingMark, section), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed with respect to the Python client is the difference section ordering:
$ reana-client diff events.1 test | grep "^==>"
==> Differences in workflow inputs
==> Differences in workflow outputs
==> Differences in workflow version
==> Differences in workflow workspace
==> Differences in workflow specification
==> Differences in workflow workspace
$ $ ./reana-client-go diff events.1 test | grep "==>"
==> Differences in workflow specification
==> Differences in workflow inputs
==> Differences in workflow outputs
==> Differences in workflow version
==> Differences in workflow workspace
==> Differences in workflow workspace
Some observations:
- It's weird that there are two "workflow workspace" sections, but that's also true for the Python client, and should be fixed there. So nothing to do here.
- Can we align the output order to respect Python client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ordering is different because GO's maps are unordered, unlike in Python. It's possible to maintain order by using json.Decoder instead of the json.Unmarshal being used. The code will probably be a little bit more verbose but the change shouldn't be too difficult
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we do it now or after package refactoring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out I was wrong about using the Decoder, it works nicely for arrays but not so much for objects, since they don't guarantee order by nature. By looking at this discussion I found some hacky workarounds but no nice solution for this, the developers don't seem to support it because one should use an array for order.
An example of a not so nice solution is using the Decoder and manually parsing the JSON, it doesn't look good at all: https://go.dev/play/p/jOXpSDpJz04
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's worth implementing this order (if we want order, shouldn't the server return it as an array?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fully agreed that it would be very clean to do this on the server-side. But since it would necessitate breaking REST API response changes, it's not something for now.
Hmm, looking at the pasted workaround, it might do actually as a stop-gap solution; however it's also possible that we can live with the Python client <-> Go client output differences for this commend, since it is not probable that some clients has wrapped it into some wider scripted glue usage scenarios... I'm kind of 60:40 split on this.
c9d5eab
to
3a28223
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works nicely 👍 The output ordering issue to be ticketised for later
closes #32