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

ci: indentation failure - why!? #1701

Closed
consideRatio opened this issue May 22, 2023 · 5 comments · Fixed by #1702
Closed

ci: indentation failure - why!? #1701

consideRatio opened this issue May 22, 2023 · 5 comments · Fixed by #1702
Assignees

Comments

@consideRatio
Copy link
Member

We error in the k8s 1.26 / main test, because the built pod can fail to startup because of an indentation error in singleuser.cmd.

image

But we don't have an indentation error in the provided config:

singleuser:
# start jupyterlab server *if available*
# fallback on jupyter-notebook
cmd:
- python3
- "-c"
- |
import os
import sys
try:
import jupyterlab
import jupyterlab.labapp
major = int(jupyterlab.__version__.split(".", 1)[0])
except Exception as e:
print("Failed to import jupyterlab: {e}", file=sys.stderr)
have_lab = False
else:
have_lab = major >= 3

Yet we have it in the pod based on k8s namespace report:
image


Is the singleuser.cmd processed in any way by us or helm making this happen? Is variable expansion involved adding a space or similar?

@manics
Copy link
Member

manics commented May 22, 2023

It's fine on main
https://github.com/jupyterhub/binderhub/actions/runs/5045025696/jobs/9048789662
Does it happen everytime on #1697 ?

@consideRatio
Copy link
Member Author

I think so, it mayyyyyy be related to rebuilding the image if its failing there, which makes chartpress do things it otherwise may not do.

@consideRatio
Copy link
Member Author

Okay this is what goes wrong:

with open(os.path.join(helm_chart, "binderhub", "values.yaml")) as values_in:
yaml.safe_dump(yaml.safe_load(values_in)["jupyterhub"], tmp.file)

Apparently this file dump doesn't represent the original YAML content.

@consideRatio
Copy link
Member Author

consideRatio commented May 22, 2023

From the binderhub repo's folder, this returns correct indentation (with non-critical indentation mistakes in the original python code) - so reading data is fine.

    import os
    from ruamel import yaml

    with open(os.path.join("helm-chart", "binderhub", "values.yaml")) as values_in:
        read_values = yaml.safe_load(values_in)
    
    print(read_values["jupyterhub"]["singleuser"]["cmd"][2])
import os
import sys

try:
    import jupyterlab
    import jupyterlab.labapp
    major = int(jupyterlab.__version__.split(".", 1)[0])
except Exception as e:
    print("Failed to import jupyterlab: {e}", file=sys.stderr)
    have_lab = False
else:
    have_lab = major >= 3

if have_lab:
  # technically, we could accept another jupyter-server-based frontend
  print("Launching jupyter-lab", file=sys.stderr)
  exe = "jupyter-lab"
else:
  print("jupyter-lab not found, launching jupyter-notebook", file=sys.stderr)
  exe = "jupyter-notebook"

# launch the notebook server
os.execvp(exe, sys.argv)

@consideRatio
Copy link
Member Author

consideRatio commented May 22, 2023

Reading, writing, and then makes it reproduce the issue. Since helm is reading it later, I presume that the writing is to blame.

import os
from ruamel import yaml

with open(os.path.join("helm-chart", "binderhub", "values.yaml")) as values_in:
    read_values = yaml.safe_load(values_in)
print(read_values["jupyterhub"]["singleuser"]["cmd"][2])

with open("dump.yaml", "w") as values_out:
    yaml.safe_dump(read_values["jupyterhub"], values_out)

with open("dump.yaml") as values_in_again:
    read_values = yaml.safe_load(values_in_again)
print(read_values["singleuser"]["cmd"][2])

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 a pull request may close this issue.

2 participants