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

fix: ngsi v2 tutorials are deprecated (#255) #259

Merged
merged 34 commits into from
Apr 30, 2024

Conversation

WaltherTrgovac
Copy link
Collaborator

As already mentioned in the issue, the pydantic method parse_file_as is causing most problems. In the commit 'attempt' I have tried to fix it, but it still isn't working. If someone could check whether the implementation is correct, that would be nice. I will also just try to get all the tutorials to work for now with this pull request and then later reformat the rest...

@WaltherTrgovac WaltherTrgovac linked an issue Mar 12, 2024 that may be closed by this pull request
@Maghnie
Copy link
Contributor

Maghnie commented Mar 13, 2024

Did you try the suggested change from #255 (comment) ?

Maybe validate_json instead of validate_python would work

However, not sure if that would fix the SERVICE_PATH error

@WaltherTrgovac
Copy link
Collaborator Author

I don't think that parsing is the problem anymore in exercise 5, but I can't get pass the error requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:4041/iot/devices. I am missing some knowledge about HTTP Errors and can't debug it...

@djs0109
Copy link
Contributor

djs0109 commented Mar 19, 2024

@WaltherTrgovac thanks for the effort! Your implementation looks good to me so far. I fix the bug you mention. The problem was, that a service group with cbHost="None" was created in e4, which is illegal regarding the data type of cbHost. Now, if you delete this service group manually via API, and redo e4 and then e5, you should be able to complete them

@WaltherTrgovac
Copy link
Collaborator Author

As of right now, exercise 5 and 6 are producing following error messages: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:1026/v2/entities/urn:ngsi-ld:Heater:001/attrs?type=Heater . Interestingly, there is one test failing in test_ngsi_v2_cb.py. The name of the test is test_command_with_mqtt. This test also produces the same error (with different url) because it is almost equivalent code as in exercise 5 and 6.
The same error (with different url) appears in e_08_ngsi_v2_iota_paho_mqtt.py and e_09_ngsi_v2_iota_filip_mqtt.py (after fixing other deprecated methods).
I am pretty sure that after solving this problem all exercises will function properly.

@WaltherTrgovac
Copy link
Collaborator Author

WaltherTrgovac commented Apr 10, 2024

Summary of this long merge request... Most changes are just formatting to keep the consistency throughout the whole tutorials.

Changes

In general, these are the changes:

  • fixed all deprecated methods
  • fixed typos (probably did not catch everything)
  • fixed PEP-8 errors that are fixable (exercise scripts are of course showing them because they need to be filled out)
  • changed all #ToDos to full sentences for consistency. If we ever want to parse each step, this helps a lot. For example,
    this kind of tutorials are optimal to be made in Jupyter Notebook.

For each exercise the changes are made:

  1. X-axis has been changed to show hours instead of minutes for better readability. time.sleep() has been reduced (controversial)
  2. Print format has been changed for better readability.
  3. Formatting
  4. X-axis has been changed to show hours instead of minutes for better readability. time.sleep() has been reduced (controversial). Each plot now has a title which increases understandability.
  5. Same as exercise 4
  6. Same as exercise 4
  7. Formatting

What has not been fixed

Exercise 5 and exercise 6 still not work properly due to the on command method (not sure whether the problem is actually here, but I am unable to fix it). This also causes weird plotting results on the x-axis which probably can not be fixed until this problem is resolved.

About the time.sleep() method

time.sleep() method is causing long execution times for the exercises. I understand that this function has to be there due to latency, but the problem is following: Let us assume that a person actually does exercises as a learning experience. It is very unlikely that the solution that the person writes is correct on the first execution. This causes that the person has to wait for tremendous amount of time in worst case for plotting to appear. I don't know whether a proper lower bound for waiting can be found but that would be my suggestion.

@WaltherTrgovac WaltherTrgovac removed the request for review from tstorek April 24, 2024 13:30
Copy link
Contributor

@djs0109 djs0109 left a comment

Choose a reason for hiding this comment

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

@WaltherTrgovac one last request for this PR. Could revise e6 as I made here? cf1659c
I think you have reverted these changes somehow, but it should be easy to fix

@WaltherTrgovac
Copy link
Collaborator Author

@WaltherTrgovac one last request for this PR. Could revise e6 as I made here? cf1659c I think you have reverted these changes somehow, but it should be easy to fix

It's done

@djs0109 djs0109 merged commit 44a7059 into master Apr 30, 2024
1 check passed
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.

ngsi_v2 tutorials are deprecated
3 participants