Skip to content

Conversation

@roznawsk
Copy link
Member

@roznawsk roznawsk commented Dec 13, 2023

  • Migrated from openapi-generator to openapi-python-client
  • Since the new generator uses ruff, switched from pylint to ruff for linting and from black for code formatting
  • Fixed the missing docs for ServerNotifications

Most changes include new models in _openapi_client and code formatting - the're probably not worth looking at.

Take a look at:

  • _room_api.py, _recording_api.py - minor changes related to the new api
  • pyproject.toml
  • poetry_scripts.py
  • _webhook_notifier.py

The tests fail, since there have been some updates in Jellyfish. The related changes will follow in the next PR.

@roznawsk roznawsk force-pushed the RTC-409-autogenerate-openapi branch 2 times, most recently from 375e31f to d077fce Compare December 14, 2023 14:05
@roznawsk roznawsk force-pushed the RTC-409-autogenerate-openapi branch from d077fce to 14051ea Compare December 14, 2023 19:14
@roznawsk roznawsk force-pushed the RTC-409-autogenerate-openapi branch from 0ad32ac to a2defad Compare December 14, 2023 19:53
@roznawsk roznawsk requested review from Karolk99 and Rados13 December 14, 2023 19:54
def _request(self, method, **kwargs):
resp = method.sync(client=self._client, **kwargs)
if isinstance(resp, Error):
raise RuntimeError(resp.errors)
Copy link
Member Author

Choose a reason for hiding this comment

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

@Rados13 Do you think it's ok to just throw a RuntimeError if a request should fail?
Before we had a couple more specific Exception types, such as UnauthorizedException, NotFoundException, BadRequestException

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that a specific Exception would be better.

@roznawsk roznawsk marked this pull request as ready for review December 14, 2023 20:25
def _request(self, method, **kwargs):
resp = method.sync(client=self._client, **kwargs)
if isinstance(resp, Error):
raise RuntimeError(resp.errors)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that a specific Exception would be better.

Copy link
Contributor

@Karolk99 Karolk99 left a comment

Choose a reason for hiding this comment

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

"In all API classes, the _request method is repeated. I suggest creating a class with a @staticmethod request, or alternatively, create a class that inherits from it."

@roznawsk roznawsk force-pushed the RTC-409-autogenerate-openapi branch from 6c338ff to 6d351b9 Compare December 15, 2023 15:23
@roznawsk roznawsk requested review from Karolk99 and Rados13 December 15, 2023 15:24
@roznawsk roznawsk changed the title Rtc 409 autogenerate openapi [RTC-409] Switch openapi generator Dec 17, 2023
import pdoc as p
from pdoc import render

# ruff: noqa: E501
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore line length in this file

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I fixed the string that was too long.

ignore = []

[tool.ruff.extend-per-file-ignores]
"jellyfish/_openapi_client/**" = ["E501"]
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore line length for autogenerated files - some comments are too long and cannot be automatically wrapped.



def receive_json(json: Dict) -> Union[server_messages]:
def receive_json(json: Dict) -> Union[SERVER_MESSAGE_TYPES]:
Copy link
Contributor

Choose a reason for hiding this comment

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

When I generate docs locally I get warnings like this:

Warn: Error parsing type annotation typing.Union[ForwardRef('ServerMessageComponentCrashed'), ForwardRef('ServerMessageHlsPlayable'), ForwardRef('ServerMessageMetricsReport'), ForwardRef('ServerMessagePeerConnected'), ForwardRef('ServerMessagePeerCrashed'), ForwardRef('ServerMessagePeerDisconnected'), ForwardRef('ServerMessageRoomCrashed'), ForwardRef('ServerMessageRoomCreated'), ForwardRef('ServerMessageRoomDeleted')] for jellyfish.receive_json. Import of ServerMessageComponentCrashed failed: name 'ServerMessageComponentCrashed' is not defined

Should it look like this? Also maybe we should add action to check if there are any warnings during docs generation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, just changed the return type of receive_json to resolve this shenanigans.

Copy link
Member Author

Choose a reason for hiding this comment

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

If warning is generated the exit code is still 0, and there is no --warning-as-errors flag. We could capture the output and check if there are any warnings, or if there is any output at all (there shouldn't be any).

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably could solve this by using env PYTHONWARNINGS=error as suggested by pdoc maintainer in this issue.

import pdoc as p
from pdoc import render

# ruff: noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

@roznawsk roznawsk requested a review from Rados13 December 18, 2023 18:04
@roznawsk roznawsk merged commit f2f6e28 into main Dec 19, 2023
@roznawsk roznawsk deleted the RTC-409-autogenerate-openapi branch December 19, 2023 15:41
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.

4 participants