[FEEDBACK] Spaces Dev Mode

#3
by sbrandeis HF staff - opened
Dev Mode Explorers org

This discussion is dedicated to feedback about Spaces' Dev Mode feature.

Your feedback is really valuable so don't hesitate to share anything about it ๐Ÿค—.

sbrandeis pinned discussion
Dev Mode Explorers org

a great feature โœจ

Dev Mode Explorers org

The feature is excellent, but when I activate dev mode, it functions correctly on my end, but it consistently displays "preparing spaces" on the public page.

(Screenshot: Taken from incognito)
image.png

I have a PRO account, and can't connect via VSCode Local or Remote for this simple gradio space.

On the web, it's stuck in endless loading.

On local, I get a timeout error. I've verified that my ssh setup is correct by following the steps here

Dev Mode Explorers org

The feature is excellent, but when I activate dev mode, it functions correctly on my end, but it consistently displays "preparing spaces" on the public page.

Thanks for reporting @KingNish - we'll work on a fix for this soon

I have a PRO account, and can't connect via VSCode Local or Remote

Thanks for reporting @arsalagrey , unfortunately I cannot reproduce this behavior. Can you try again to confirm it still does not work for you?

It would be helpful if you could share more information about this issue, for example:

  • Can you SSH into the Space (using SSH, not VSCode) ?
  • Is there any error when you try to SSH into the Space?
  • Is there any error when you try to connect to the Space with your local VS Code?

When using VS Code local, make sure you have the Remote - SSH VS Code extension installed.

Dev Mode Explorers org

@KingNish the issue you reported should be fixed now, can you confirm it works as expected on your side?

Dev Mode Explorers org

@sbrandeis Yes, it's working fine. Thank you!

Disregard.

@bkoz

This is a great feature, but the modal blocks the Space's UI. Can you add a feature to minimize it?

Dev Mode Explorers org

This is a great feature, but the modal blocks the Space's UI. Can you add a feature to minimize it?

You can minimize it by clicking arrow above dev mode block.

I cannot see any arrow, please check attached screenshot.
devmode.png

Dev Mode Explorers org
Dev Mode Explorers org
โ€ข
edited May 21

I cannot see any arrow, please check attached screenshot.
devmode.png

I guess heres a 'whatever' issue,-> Arrow doesnt switch colors depending on dark/light mode?

Dev Mode Explorers org

cc @victor on the above ^

Dev Mode Explorers org

Yes it should :D

I have a PRO account, and can't connect via VSCode Local or Remote for this simple gradio space.

On the web, it's stuck in endless loading.

On local, I get a timeout error. I've verified that my ssh setup is correct by following the steps here

I'm getting related errors and cannot seem to get the local VSCode Connection to work.

Keep getting messages like:
"@ssh.hf.space: Permission denied (publickey).
local-server-1> ssh child died, shutting down

[21:57:53.411] Resolver error: Error: Permission denied (publickey)."

Dev Mode Explorers org

@NicDev make sure your ssh key is stored in your hf account

Yeah it is, i also follwed the ssh setup steps mentioned here

Edit: Maybe I should add to this, I found only some threads that were related to this issue.

https://github.com/microsoft/vscode-remote-release/issues/6521 --> Suggests to set "remote.SSH.useLocalServer": false; on my end, this makes the SSH connection request run veery long/endlessly, never finishes.
https://stackoverflow.com/questions/60675232/ssh-in-vscode-error-permission-denied-publickey-password --> is related to the config file, didn't help

Maybe also worth mentioning: It fails precisely after prompting me to insert the passphrase 3 times.

Hi,
I have had a problem recently that turned out to be Dev Mode-related:
Upon factory rebuild of my spaces, nothing installed from requirements.txt or packages.txt.
Just turning dev mode off solved it, and everything installed as it should upon rebuild. Also worked turning on dev mode again after that.

Hopefully it gets fixed, but if you have the same problem just turn off Dev Mode if you are rebuilding pushing changes to requirements.txt/packages.txt!

Oh never mind just found this on the dev-mode-explorers page:

If you're using the Streamlit or Gradio SDK, or if your application is Pyhton-based, note that requirements are not installed automatically. You will need to manually run pip install from VS Code or SSH.

So I guess it's expected, but not well documented I have to say! Works great anyway so thanks!

Hi everyone,
i wanted to try the dev mode, ultimately with the intention to streamline my dev flow using pycharm.
I set up the ssh key and can connect using the console.
It seems the ssh connection is working in pycharm (didnt get it to connect using termius, despite the log showing successfull authentication)
It seems the SFTP connection is failing.
To double check: Is the intention that file down- and upload is possible via SFTP to the space?

One thing I noticed is, that the "Git status" widget is not finishing:
image.png

Appreciate any input.
Thanks

Dev Mode Explorers org

It seems the SFTP connection is failing.

Hi @tengel , to upload files to your space we advise using rsync rather than SFTP. The SFTP protocol is not supported on our side.

didnt get it to connect using termius

Could you get some logs from the ssh connection from termius?

Appreciate your input @mcpotato , thanks.

@SFTP: thats a pity, pycharm would support it out of the box. I tried with the rsync option within pycharm, but it seems it still tries to use SFTP for authentication and rsync then for the data transfer. From the command line trying rsync fails as the remote side does not have to seem rsync available (logged in via ssh, tried to find it)

Any thoughts about adding SFTP support in the future?

@Termius log:
๐Ÿ‘ค Starting a new connection to: "ssh.hf.space" port "22"
โš™๏ธ Starting address resolution of "ssh.hf.space"
โš™๏ธ Address resolution finished
โš™๏ธ Connecting to "18.205.32.140" port "22"
๐Ÿ‘ค Connection to "ssh.hf.space" established
โš™๏ธ Starting SSH session
โš™๏ธ Remote server: SSH-2.0-russh_0.43.0
โš™๏ธ Agreed KEX algorithm: curve25519-sha256
โš™๏ธ Agreed Host Key algorithm: ssh-ed25519
โš™๏ธ Agreed server-to-client cipher: [email protected] MAC: INTEGRATED-AES-GCM
โš™๏ธ Agreed client-to-server cipher: [email protected] MAC: INTEGRATED-AES-GCM
โš™๏ธ Agreed client-to-server compression: none
โš™๏ธ Agreed server-to-client compression: none
โš™๏ธ Handshake finished
๐Ÿ‘ค Checking host key: 9a:11:8b:d7:f7:58:56:93:a4:d1:c3:c2:b0:81:86:aa
๐Ÿ‘ค Host "ssh.hf.space":"22" is known and matches
๐Ÿ‘ค Authenticating to "ssh.hf.space":"22" as "tengel-devmodetest"
โš™๏ธ Available client authentication methods: publickey,password,keyboard-interactive
โš™๏ธ Authentication that can continue: publickey
๐Ÿ‘ค Authenticating using publickey method
๐Ÿ‘ค Authentication succeeded (publickey)
๐Ÿ‘ค Authenticated to "ssh.hf.space":"22"

image.png
Surprisingly, the log does not even show the failed connection, only the GUI.

Dev Mode Explorers org

rsync fails as the remote side does not have to seem rsync available

Are you using a custom Dockerfile for your space? You must install rsync yourself if so. Otherwise, rsync should be installed by default in your space.

Any thoughts about adding SFTP support in the future?

It's complicated and would require some work to do so. If we have sufficient demand from the community we can think about it, otherwise no.

Hi everyone,

I've started a space using the docker template "jupyter-lab" and enabled dev mode. I'm using a local VS code.
When running my script on gpu, I can't find the PID with nvidia-smi.

This is perhaps related to this issue: --pid=host should be specified when running the docker container.

Any idea on how to solve this ?

image.png

I managed to get to a "Initializing VS Code Server" popup, but now it seems to hang. How long did the initialization take for others?
That is the last output I have in my terminal:

Console Output
"[13:03:36.654] > 0c04245dcbc7: running
> Found existing installation at /home/user/.vscode-server...
> Starting VS Code CLI... "/home/user/.vscode-server/code-611f9bfce64f25108829dd29
> 5f54a6894e87339d" command-shell --cli-data-dir "/home/user/.vscode-server/cli" -
> -on-port --on-host=127.0.0.1 --parent-process-id 10373 &> "/home/user/.vscode-se
> rver/.cli.611f9bfce64f25108829dd295f54a6894e87339d.log" < /dev/null
> printenv:
>     NVIDIA_VISIBLE_DEVICES=all
>     KUBERNETES_SERVICE_PORT_HTTPS=443
>     KUBERNETES_SERVICE_PORT=443
>     PERSISTANT_STORAGE_ENABLED=false
>     PYTHONUNBUFFERED=1
>     PYTORCH_NVML_BASED_CUDA_CHECK=1
>     GRADIO_THEME=huggingface
>     HOSTNAME=r-razzfazz-io-vs-code-connection-test-bafy8t0k-a9bed-8gcjd
>     SPACE_HOST=razzfazz-io-vs-code-connection-test.hf.space
>     TQDM_POSITION=-1
>     PWD=/home/user/app
>     SPACES_ZERO_GPU=1
>     SPACES_ZERO_DEVICE_API_URL=http://device-api.zero
>     NVIDIA_DRIVER_CAPABILITIES=compute,utility
>     TZ=Europe/Paris
>     HOME=/home/user
>     KUBERNETES_PORT_443_TCP=tcp://172.20.0.1:443
>     SPACE_SUBDOMAIN=razzfazz-io-vs-code-connection-test
>     GRADIO_SERVER_NAME=0.0.0.0
>     VSCODE_AGENT_FOLDER=/home/user/.vscode-server
>     HF_DATASETS_TRUST_REMOTE_CODE=0
>     HF_HUB_ENABLE_HF_TRANSFER=1
>     GRADIO_CACHE_EXAMPLES=lazy
>     PYTHONPATH=/home/user/app
>     TQDM_MININTERVAL=1
>     GRADIO_NUM_PORTS=1
>     SPACE_ID=razzfazz-io/vs-code-connection-test
>     CPU_CORES=64
>     SPACE_AUTHOR_NAME=razzfazz-io
>     SHLVL=1
>     SYSTEM=spaces
>     KUBERNETES_PORT_443_TCP_PROTO=tcp
>     KUBERNETES_PORT_443_TCP_ADDR=172.20.0.1
>     SPACE_TITLE=Vs Code Connection Test
>     GRADIO_ALLOW_FLAGGING=never
>     SPACE_REPO_NAME=vs-code-connection-test
>     KUBERNETES_SERVICE_HOST=172.20.0.1
>     KUBERNETES_PORT=tcp://172.20.0.1:443
>     KUBERNETES_PORT_443_TCP_PORT=443
>     PATH=/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> :/sbin:/bin
>     GRADIO_DEFAULT_CONCURRENCY_LIMIT=None
>     MEMORY=64Gi
>     DEBIAN_FRONTEND=noninteractive
>     _=/usr/bin/printenv
> Removing old logfile at /home/user/.vscode-server/.cli.611f9bfce64f25108829dd295
> f54a6894e87339d.log
> Spawned remote CLI: 10397
"

Well, after trying to get a Docker Space with dev mode running, I have some additional feedback:

As it is now, you cannot edit files directly in the space when dev mode is activated.
But, the way I see it, if the build fails, e.g. because your docker file is broken, you need to disable dev mode anyway, because you can't access a space that is not running via ssh.

So in the case of a build error, would it be feasible to deactivate devmode automatically?

Also, permissions were broken for me with the default docker file as suggested in the tutorial. I was not able to create any files or directories using that.

Dev Mode Explorers org
โ€ข
edited 6 days ago

Also, permissions were broken for me with the default docker file as suggested in the tutorial. I was not able to create any files or directories using that.

Thank you for reporting this - are you referring to the Dockerfile from the page here (in the "Example of a compatible Dockerfile" section)?

Ah, thank you for pointing that out... should have scrolled down ;)

No, in my case I created a blank docker space and followed the first steps as provided. But these might be for non dev mode spaces then?
I managed to get permissions kinda fixed, but now I am unsure if this leads to other problems down the line. I'll try complying to the config example in the readme.

Just for reference, my Dockerfile:

Dockerfile
FROM python:3.11

RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

COPY --chown=user ./requirements.txt requirements.txt

RUN pip install --no-cache-dir --upgrade -r requirements.txt

COPY --chown=user . /app

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

Also, permissions were broken for me with the default docker file as suggested in the tutorial. I was not able to create any files or directories using that.

Thank you for reporting this - are you referring to the Dockerfile from the page here (in the "Example of a compatible Dockerfile" section)?

There is one small error in the example:

FROM node:19-slim

RUN RUN apt-get update && \ #Error here: second RUN is wrong
    apt-get install -y \
      bash \
      git git-lfs \
      wget curl procps \
      htop vim nano && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --link --chown=1000 ./ /app
RUN  npm ci 

CMD ["node", "index.mjs"]
Dev Mode Explorers org
โ€ข
edited 6 days ago

There is one small error in the example

Indeed! Would you like to open a PR to fix this?
https://huggingface.co/spaces/dev-mode-explorers/README/edit/main/README.md

Dev Mode Explorers org

No, in my case I created a blank docker space and followed the first steps as provided. But these might be for non dev mode spaces then?

Got it!
We should update those instructions so they are compatible with the dev mode, thank you your pointing this out!

There is one small error in the example

Indeed! you like to open a PR to fix this?
https://huggingface.co/spaces/dev-mode-explorers/README/edit/main/README.md

Can do. But one other question beforehand.
I needed to add creating a user to the file, because I got a build error when git tried to assign my git username.

My working Dockerfile now looks like this:

FROM python:3.11

RUN apt-get update && \
    apt-get install -y \
      bash \
      git git-lfs \
      wget curl procps \
      htop vim nano && \
    rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user #seems only this was missing for me

WORKDIR /app

COPY --link --chown=1000 ./ /app

RUN pip install --no-cache-dir --upgrade -r requirements.txt

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

Should I add this as well in the PR?

Dev Mode Explorers org

Yes that would be awesome! Thanks

Done. :)

Sign up or log in to comment