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

Change np.ndarray types to list type to fix model serialization to fix OpenAPISpec and SwaggerUI (2) #986

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

Conversation

gabauer
Copy link

@gabauer gabauer commented Oct 2, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Bug fix

  • What is the current behavior? (You can also link to an open issue here)
    In Marqo 2.x, OpenAPI spec generation is not functional. Attempting to access /openapi.json or /docs results in errors, making it impossible to retrieve the API specifications and documentation. This issue is documented in Issue #778.

  • What is the new behavior (if this is a feature change)?
    This PR restores OpenAPI spec generation and resolves the issues with the /openapi.json and /docs endpoints. The root cause was identified in src/marqo/tensor_search/models/add_docs_objects.py, where the documents field included a union type that couldn't be serialized due to the presence of np.ndarray.

By replacing np.ndarray with the standard Python list type in the union, the serialization issue is resolved, allowing OpenAPI specs and Swagger UI to function as expected.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No, this PR does not introduce any breaking changes. Existing functionalities remain unaffected, and users do not need to make any changes to their applications.

  • Have unit tests been run against this PR? (Has there also been any additional testing?)
    No, unit tests haven't been executed. I locally confirmed that the OpenAPI specification and Swagger UI are now accessible and operational.

  • Related Python client changes (link commit/PR here)
    No related changes in the Python client.

  • Related documentation changes (link commit/PR here)
    No changes needed as the fix restores a functionality already documented.

  • Other information:
    The issue was addressed by considering three potential solutions:

  1. Implementing a custom OpenAPI function in FastAPI to exclude np.ndarray fields from the schema.
  2. Creating a custom JSON encoder for models containing np.ndarray.
  3. Replacing np.ndarray with a standard Python list type.

The third option was chosen for its simplicity and effectiveness.

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added / updated (for bug fixes / features)

@papa99do
Copy link
Collaborator

@gabauer , sorry for the long wait. We've pinpointed that the permission issue to run github actions for your PR because forked PR cannot access action secrets. We are currently working on a fix to allow access. I'll keep you updated and merge your change in once the build is triggered and passed. Thanks.

@gabauer
Copy link
Author

gabauer commented Oct 14, 2024

@papa99do No worries, I meanwhile also startet writing a java client based on feign, as non of the generated clients worked well for java. Let me just know if I have to do something like rebasing or something else.

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.

2 participants