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

Swagger UI freezes when expanding specific endpoints #337

Closed
turbomam opened this issue Oct 30, 2023 · 7 comments · Fixed by #338
Closed

Swagger UI freezes when expanding specific endpoints #337

turbomam opened this issue Oct 30, 2023 · 7 comments · Fixed by #338
Assignees
Labels
bug Something isn't working upstream-issue The root cause lies upstream from here

Comments

@turbomam
Copy link
Member

@brynnz22 and I are having trouble just accessing the swagger interface for submitting a changesheet.

@dwinston or @eecavanna can you please look into this or delegate it to somebody else?

@eecavanna
Copy link
Collaborator

I'll start digging into this (as my highest priority) by 2:30pm PT. Thanks for bringing it to my/our attention.

@eecavanna
Copy link
Collaborator

Here's the URL of the web page in question: https://api.microbiomedata.org/docs

As of 2:37pm PT on Monday 10/31, it is loading OK for me in Brave browser Version 1.57.47 Chromium: 116.0.5845.96 (Official Build) (arm64).

I will check Rancher to see whether it was recently rebooted.

@eecavanna
Copy link
Collaborator

I confirmed, via Rancher, that neither pod rebooted within the last 7 days.

image

Next, I'll check the pods' container logs.

@eecavanna eecavanna changed the title swagger API pins CPUs and freezes Swagger UI freezes when expanding specific endpoints Oct 30, 2023
@eecavanna eecavanna added bug Something isn't working upstream-issue The root cause lies upstream from here decision needed tag issues that need to be unblocked by decisions labels Oct 30, 2023
@eecavanna
Copy link
Collaborator

I think this is happening due to a bug in Swagger UI.

  • Swagger UI v5.9.1 introduced a bug
    • The bug affects the expansion of sections describing endpoints whose schemas are large
  • FastAPI v0.104.1 introduced a workaround for the bug
    • The workaround is to pin (i.e. lock) Swagger UI to version v5.9.0 until the upstream bug gets fixed
  • nmdc-runtime currently uses FastAPI version 0.103.2
  • I want to update nmdc-runtime to use FastAPI v0.104.1 so it gets this bugfix.

@dwinston, I've never updated the fastapi dependency of nmdc-runtime. Do you have a particular process for updating a core dependency like that?

https://github.com/microbiomedata/nmdc-runtime/blob/46d6543339d2436524475a624644652d901a6517/requirements/main.txt#L180C17-L181

@eecavanna
Copy link
Collaborator

More details are in this Slack thread.

@dwinston
Copy link
Collaborator

Thanks for the investigation, @eecavanna! I'll draft a PR for this.

@dwinston
Copy link
Collaborator

dwinston commented Oct 31, 2023

  1. I first updated the dep in requirements/main.in:
# requirements/main.in
fastapi>=0.104.1 # Pins Swagger UI version to 5.9.0 temporarily to handle a bug crashing it in 5.9.1
  1. I then ran make update to update requirements/main.txt.

  2. Next, I ran make up-dev to rebuild containers using the latest requirements/main.txt.

  3. ran docker compose logs -f fastapi and noticed this error:

fastapi  | pydantic.errors.PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.
  1. Updated all @root_validator decorations as required (leaving refactoring to @model_validator to a later time / separate PR)

  2. Re-ran make up-dev. Noticed another pydantic-upgrade error via docker compose logs -f fastapi:

fastapi  | TypeError: constr() got an unexpected keyword argument 'regex'
  1. Ran a 'Replace in Files' process to take constr(regex= to constr(pattern= throughout the codebase (~10 instances) after jumping to and inspecting constr source (cmd+b in pycharm). Re-ran make up-dev. Another pydantic-upgrade error:
fastapi  |   File "/code/components/nmdc_runtime/workflow_execution_activity/spec.py", line 12, in <module>
fastapi  |     class ActivityTree(BaseModel):
fastapi  |   File "/usr/local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 184, in __new__
fastapi  |     complete_model_class(
...
fastapi  |     raise PydanticSchemaGenerationError(
fastapi  | pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'nmdc_schema.nmdc.WorkflowExecutionActivityId'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
  1. Added model_config = ConfigDict(arbitrary_types_allowed=True) to class. Noting here briefly that linkml-generated nmdc-schema clases may have an issue with pydantic v2. Re-ran stuff; Another pydantic-upgrade error:
fastapi  | pydantic_core._pydantic_core.ValidationError: 1 validation error for ObjectType
fastapi  | description
fastapi  |   Field required [type=missing,
  1. It seems description: Optional[str] no longer means a field is optional. Changed all instances in codebase to description: Optional[str] = None. Re-ran make up-dev, and see "Application startup complete" via docker compose logs -f fastapi

  2. confirmed that http://localhost:8000/docs#/metadata/submit_changesheet_metadata_changesheets_submit_postloads without issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-issue The root cause lies upstream from here
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants