jupyterhub / kubespawner

Kubernetes spawner for JupyterHub
https://jupyterhub-kubespawner.readthedocs.io
BSD 3-Clause "New" or "Revised" License
550 stars 304 forks source link

c.KubeSpawner.environment not interpreting callables #824

Closed Khagesh16 closed 8 months ago

Khagesh16 commented 9 months ago

Bug description

This change is causing an issue when the environment accepts the callable function. https://github.com/jupyterhub/kubespawner/pull/759

This same piece of logic used to be working on version 5.0.0 but failing on the latest version.

How to reproduce

This is a sample dictionary which we are passing to c.KubeSpawner.environment with other environment variables.

{
    "JUPYTERHUB_SINGLEUSER_APP": "jupyter_server.serverapp.ServerApp",
    "USERNAME": lambda spawner: str(spawner.user.name),
    "JUPYTER_ENABLE_LAB": "yes",
    "AWS_STS_REGIONAL_ENDPOINTS": "regional",
}
  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behaviour

It should replace the username with actual username

{
    "CPU_LIMIT": "3.0",
    "CPU_GUARANTEE": "2.0",
    "JUPYTERHUB_SINGLEUSER_APP": "jupyter_server.serverapp.ServerApp",
    "USERNAME": "kpandya",
    "JUPYTER_ENABLE_LAB": "yes"}

Actual behaviour

{"CPU_LIMIT": "3.0",
    "CPU_GUARANTEE": "2.0",
    "JUPYTERHUB_DEFAULT_URL": "/lab",
    "JUPYTERHUB_SINGLEUSER_APP": "jupyter_server.serverapp.ServerApp",
    "USERNAME": < function < lambda > at 0x7ff12b035120 > ,
    "JUPYTER_ENABLE_LAB": "yes"}

Your personal set up

Full environment ``` # paste output of `pip freeze` or `conda list` here ```
Configuration ```python # jupyterhub_config.py ```
Logs ``` # paste relevant logs here, if any ```
welcome[bot] commented 9 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

jabbera commented 8 months ago

This is a dupe of https://github.com/jupyterhub/kubespawner/issues/815