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

add representation methods and encoders #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arfio
Copy link
Contributor

@arfio arfio commented Jul 4, 2024

This method adds encoders to be able to easily store the responses in json format.
It also adds repr() method to used models to be able to print and easily see what is contained in a response.

Copy link
Contributor

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Arnaud, I am wondering what the end game is here. Could you describe it in a comment or commit message? It'll allow the reviews to be better directed.

@arfio
Copy link
Contributor Author

arfio commented Jul 5, 2024

The encoders are useful to store objects on disk between multiple calls to a program. This is useful in some cases where you need to recover the previous state of your run.
The representations implementation is very useful to print the results of the requests to know what you got. It is very useful for debugging and testing out things when developping.

MatthewKhouzam
MatthewKhouzam previously approved these changes Jul 5, 2024
MatthewKhouzam
MatthewKhouzam previously approved these changes Jul 19, 2024
bhufmann
bhufmann previously approved these changes Jul 19, 2024
Copy link
Collaborator

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It has some merge conflicts right now with latest in master branch. @arfio, could you please rebase it?

MatthewKhouzam
MatthewKhouzam previously approved these changes Jul 23, 2024
Copy link
Contributor

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge with might

Copy link
Collaborator

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. When testing I encountered some issues which I ask you to address.

I had to add some code to test the additions. Is there a way to provide some tests?
(please remember when running pytest, the trace server workspace is wiped out, so run it on a new workspace)

tsp/tsp_client_response.py Outdated Show resolved Hide resolved
tsp/tsp_client_response.py Outdated Show resolved Hide resolved
tsp/tsp_client_response.py Outdated Show resolved Hide resolved
tsp/tsp_client.py Outdated Show resolved Hide resolved
tsp/tsp_client_response.py Outdated Show resolved Hide resolved
series.print(array_print)

def __repr__(self):
return f'XYModel(title={self.title}, series={self.series})'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the print method was removd and hence calling ./tsp_cli_client --get-xy OUTPUT_ID --uuid UUID --items ITEMS --time-range START END NUM_TIMES fails:

Traceback (most recent call last):
  File "/home/user/git/tsp-python-client/./tsp_cli_client", line 423, in <module>
    xyModel.print(array_print=True)
AttributeError: 'XYModel' object has no attribute 'print'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it using the repr instead. If a pretty print is needed for the CLI then it can be implemented but I feel like it is not needed here.

tsp/tsp_client_response.py Show resolved Hide resolved
tsp/xy_model.py Show resolved Hide resolved
tsp/tsp_client_response.py Show resolved Hide resolved
@arfio
Copy link
Contributor Author

arfio commented Sep 12, 2024

Thank you for the review, there were indeed quite a few bugs to fix. I wonder if there is a good way of validating these functionalities, should we just validate that no exceptions are raised ? or should we validate that the strings generated are equal to test strings ?

This might require a lot of additional tests and code that might change in the future. What do you think ?

@arfio
Copy link
Contributor Author

arfio commented Oct 3, 2024

The CI failed because on an issue with the trace server, it should be fixed when eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#89 is merged.

@arfio arfio requested a review from bhufmann October 4, 2024 15:23
The encoders are useful to store objects on disk between multiple
calls to a program. This is useful in some cases where you need
to recover the previous state of your run.

The representations implementation is very useful to print the
results of the requests to know what you got. It is very useful
for debugging and testing out things when developping.

Signed-off-by: Arnaud Fiorini <[email protected]>
@bhufmann
Copy link
Collaborator

Thank you for the review, there were indeed quite a few bugs to fix. I wonder if there is a good way of validating these functionalities, should we just validate that no exceptions are raised ? or should we validate that the strings generated are equal to test strings ?

This might require a lot of additional tests and code that might change in the future. What do you think ?

It's not easy to verify print-outs. They can change easily. You could verify some content that it's known to be there, but don't compare IDs or order that can change during multiple executions.

Ideally there would be some test cases which could be used to test and helps to know how to use it. It doesn't need to be exhausting tests, but it would help. I had to read the code and google search to know how to try it.

I'm ok to merge it as is, but it would be good to have an "hello world" test case for example purposes.

Copy link
Collaborator

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me now. Thanks.

@bhufmann
Copy link
Collaborator

@MatthewKhouzam are you still ok with this PR after the updates?

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.

3 participants