Sage-Bionetworks / sage-monorepo

Where OpenChallenges, Schematic, and other Sage open source apps are built
https://sage-bionetworks.github.io/sage-monorepo/
Apache License 2.0
21 stars 12 forks source link

[Story] Create OC API client for Python #2236

Closed tschaffter closed 8 months ago

tschaffter commented 9 months ago

What product(s) is this story for?

OpenChallenges

As a user, I want

No response

Description

Use the project template schematic-api-client-python I created.

This client will be used to access OC API in a Python script or notebook.

Acceptance criteria

No response

Tasks

No response

Anything else?

No response

Have you linked this story to a GitHub Project?

tschaffter commented 9 months ago

Unable to serve the project openchallenges-notebook

It has been a while since we have used this project. The task prepare completes successfully. However, running the task server throws an error:

$ nx serve openchallenges-notebook

> nx run openchallenges-notebook:serve

Traceback (most recent call last):
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/bin/jupyter-lab", line 5, in <module>
    from jupyterlab.labapp import main
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyterlab/labapp.py", line 13, in <module>
    from jupyter_server.serverapp import flags
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyter_server/serverapp.py", line 28, in <module>
    from jupyter_client.kernelspec import KernelSpecManager
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyter_client/__init__.py", line 8, in <module>
    from .asynchronous import AsyncKernelClient  # noqa
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyter_client/asynchronous/__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyter_client/asynchronous/client.py", line 6, in <module>
    from jupyter_client.channels import HBChannel
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/jupyter_client/channels.py", line 12, in <module>
    import zmq.asyncio
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/__init__.py", line 103, in <module>
    from zmq import backend
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/backend/__init__.py", line 31, in <module>
    raise original_error from None
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/backend/__init__.py", line 26, in <module>
    _ns = select_backend(first)
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/backend/select.py", line 31, in select_backend
    mod = import_module(name)
  File "/home/vscode/.pyenv/versions/3.9.2/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
    from . import (
ImportError: /workspaces/sage-monorepo/apps/openchallenges/notebook/.venv/lib/python3.9/site-packages/zmq/backend/cython/../../../pyzmq.libs/libzmq-68c212d3.so.5.2.4: ELF file's phentsize not the expected size
Warning: run-commands command "poetry run jupyter lab --config=jupyter_lab_config.py" exited with non-zero status code

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target serve for project openchallenges-notebook failed

Solution

Updating Python from v9 to v10 solved the issue.

tschaffter commented 9 months ago

I have the following validation error when querying the first page of challenges:

ValidationError: 1 validation error for Challenge
description
  ensure this value has at most 280 characters (type=value_error.any_str.max_length; limit_value=280)

Solution: Update the API description that included on old length for the description.

tschaffter commented 9 months ago

The error is now:

ValidationError: 1 validation error for Challenge
name
  ensure this value has at most 60 characters (type=value_error.any_str.max_length; limit_value=60)

Solution: Update the max length of the challenge slug and name to 255 as defined at the table level.