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

cli: implement diff command #82

Merged
merged 3 commits into from Aug 19, 2022
Merged

Conversation

BrunoRosendo
Copy link
Member

closes #32

if len(lines) != 0 {
equalSpecification = false
utils.PrintColorable(
fmt.Sprintf("%s Differences in workflow %s\n", leadingMark, section),
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member Author

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?)

Copy link
Member

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.

Copy link
Member

@tiborsimko tiborsimko left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: implement diff command
2 participants