GithubHelp home page GithubHelp logo

abhishekkrthakur / colabcode Goto Github PK

View Code? Open in Web Editor NEW
2.0K 2.0K 278.0 33 KB

Run VSCode (codeserver) on Google Colab or Kaggle Notebooks

License: MIT License

Python 55.61% Jupyter Notebook 43.49% Makefile 0.90%

colabcode's Introduction

ColabCode

license PyPI version python version

Installation

$ pip install colabcode

Run code server on Google Colab or Kaggle Notebooks.

Getting Started

ColabCode also has a command-line script. So you can just run colabcode from command line.

colabcode -h will give the following:

usage: colabcode [-h] --port PORT [--password PASSWORD] [--mount_drive]

ColabCode: Run VS Code On Colab / Kaggle Notebooks

required arguments:
  --port PORT          the port you want to run code-server on

optional arguments:
  --password PASSWORD  password to protect your code-server from unauthorized access
  --mount_drive        if you use --mount_drive, your google drive will be mounted

Else, you can do the following:

# import colabcode
$ from colabcode import ColabCode
# run colabcode with by default options.
$ ColabCode()
# ColabCode has the following arguments:
# - port: the port you want to run code-server on, default 10000
# - password: password to protect your code server from being accessed by someone else.
#             Note that there is no password by default!
# - mount_drive: True or False to mount your Google Drive
$ ColabCode(port=10000, password="abhishek", mount_drive=True)

How to use it?

Colab starter notebook: ย ย  Open In Colab

ColabCode comes pre-installed with some VS Code extensions.

See an example in youtube video

YouTube Video

License

MIT

colabcode's People

Contributors

abhishekkrthakur avatar ahtyamovdanil avatar apthagowda97 avatar dgbkn avatar dumbris avatar jeremyjordan avatar misalraj avatar skander-hadjromdhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colabcode's Issues

Starting with `mount_drive=True` hangs startup

When the option to mount the drive is specified;

ColabCode(port=10000, password="pass", authtoken="[ngroktoken]", mount_drive=True)

... it will only start as:

Code Server can be accessed on: NgrokTunnel: "https://[tunnelid[.ngrok.io" -> "http://localhost:10000"

... and just hang. Any idea?

python extension issue

when i try to set the interpreter via the Command Palette I get -
"Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)"

I can execute the python code in the terminal and the python extension looks like it's installed but I can't get it to work. I've tried installing older versions of python after finding some others with the same issue but this didn't resolve the issue either.

Anyone else with this issue or with a workaround?

Add telebit.cloud support

I think ngrok is too limited. I tried installing an extension, some error shown in the bottom left corner, and then error from ngrok. "No concurrent connection more than 20" or something like that.

Telebit.cloud is better for port forwarding. But I think it'll take much time to install and difficult to implement.

Terminal Blank

This is an issue that my friend faced. So basically, if you run a ColabCode instance, and you get a blank terminal in VSCode,
Solution: Go to File -> Preferences -> Setting -> Features -> Terminal -> Split Cwd and change it to 'initial' and your terminal should work now.

CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected

Started colabcode from the colab_starter.ipynb notebook.
I ran this code on the vscode session in browser:

from tensorflow.python.client import device_lib
import os


def get_available_gpus():
    local_device_protos = device_lib.list_local_devices()
    return [x.name for x in local_device_protos if x.device_type == 'GPU']

print(get_available_gpus())

and got this output:

2020-09-22 06:04:37.823495: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-09-22 06:04:38.942761: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2249995000 Hz
2020-09-22 06:04:38.943092: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x22f8a00 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-09-22 06:04:38.943117: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-09-22 06:04:38.944475: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-09-22 06:04:38.947013: E tensorflow/stream_executor/cuda/cuda_driver.cc:314] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-09-22 06:04:38.947042: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (6018e5e49baf): /proc/driver/nvidia/version does not exist

Can we run colabcode on AWS Sagemaker notebooks?

Tried running on AWS Notebook instance
Failed with the following error
Is something different with Sagemaker session, apart from google colab or kaggle?

<ipython-input-16-e0886fae08fe> in <module>
      3 
      4 # run colabcode with by deafult options.
----> 5 ColabCode(password='1234')

~/anaconda3/envs/python3/lib/python3.6/site-packages/colabcode/code.py in __init__(self, port, password, authtoken, mount_drive)
     21         self._mount = mount_drive
     22         self._install_code()
---> 23         self._install_extensions()
     24         self._start_server()
     25         self._run_code()

~/anaconda3/envs/python3/lib/python3.6/site-packages/colabcode/code.py in _install_extensions(self)
     33     def _install_extensions(self):
     34         for ext in EXTENSIONS:
---> 35             subprocess.run(["code-server", "--install-extension", f"{ext}"])
     36 
     37     def _start_server(self):

~/anaconda3/envs/python3/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
    421         kwargs['stdin'] = PIPE
    422 
--> 423     with Popen(*popenargs, **kwargs) as process:
    424         try:
    425             stdout, stderr = process.communicate(input, timeout=timeout)

~/anaconda3/envs/python3/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    727                                 c2pread, c2pwrite,
    728                                 errread, errwrite,
--> 729                                 restore_signals, start_new_session)
    730         except:
    731             # Cleanup if the child failed starting.

~/anaconda3/envs/python3/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1362                         if errno_num == errno.ENOENT:
   1363                             err_msg += ': ' + repr(err_filename)
-> 1364                     raise child_exception_type(errno_num, err_msg, err_filename)
   1365                 raise child_exception_type(err_msg)
   1366 

FileNotFoundError: [Errno 2] No such file or directory: 'code-server': 'code-server'```

Blank Screen on Run

Hi,

Recently whenever i have tried to use and Run the Collab ... then i go to *.ngrok.io site... It does not show any thing after login page.... I've tried in multiple browsers...

Can anyone check ?

Connect other local/remote IDE

Hi, great tool, would it be possible to connect also some other local/remote IDE like PyCharm?
If so, could we add it also to the readme... ๐Ÿฐ

Jupyter: ms-toolsai.jupyter

I have been having many problems with this extension

  1. I am using this Jupyter notebook as an extension to run my Python ipynb files but every time I go to run it it runs in the console instead of the notebook
  2. It is reset to Python instead of Jupyter every time I try to run it. How do I get them to stop returning to Python and stay on the Jupyter setting?
  3. I want to be able to use Python extension without this Jupyter notebook extension as the previous version was much more friendly, how do I do that?
    Screen Shot 2020-11-12 at 2 24 08 PM
    Screen Shot 2020-11-12 at 2 27 27 PM

Unable to access competition data from Kaggle

I am not able to access the competition data after logging into the code server.
Are there any additional steps or commands needed to do this? I've followed the tutorial based on the Youtube video.

image
image

site is not opening

I have never used ngrok before, after I followed the tutorial on youtube, clicking on the link did not work. It asked for the password and after that all I could see is a blank page. Is ngrok installed in colab machine by default? What is the solution? I also tried to create an account on ngrok, but that also did not help

Too many connections! The tunnel session 'ts_1hlqlpmaWrbJN1bOTucLT1dsx2M'

Too Many Connections

Too many connections! The tunnel session 'ts_1hlqlpmaWrbJN1bOTucLT1dsx2M' has violated the rate-limit policy of 20 connections per minute by initiating 26 connections in the last 60 seconds. Please decrease your inbound connection volume or upgrade to a paid plan for additional capacity.

The error encountered was: ERR_NGROK_702

What does this even mean?
I tried using code server as always. Throws unprecedented error.

Getting Too many connections error on running

Hi,
I am encountering the following error when I try to run colabcode

`
Too many connections! The tunnel session 'ts_1haqep9AXrK0M55zyQFF0HgWbVH' has violated the rate-limit policy of 20 connections per minute by initiating 36 connections in the last 60 seconds. Please decrease your inbound connection volume or upgrade to a paid plan for additional capacity.

The error encountered was: ERR_NGROK_702
`
Kindly suggest how to resolve it.

Python interpreter depends on unreachable ms-toolsai.jupyter

On colab after successful setup and entering VS Code I got
fig1
and after trying to run file
fig2
but VS Code couldn't install this extension, it reports it couldn't be found.

The same happens on Kaggle too.

I used Chrome (86.0.4240.198) and Firefox (82.0.3).

How to save the code as a python file?

I was working on a kaggle competition and after sometime the code server stops and all the files created were gone.
Is there any way to save the files in the present working directory ?

How to open Jupyter Lab and VS-code server?

Hi,

I tried running ColabCode(port=1000) then it works fine and am able to open code server.

But, i also want to open Jupyter lab along with code server. So, i looked at the code and Found default lab=False

So, when i tried running ColabCode(port=10000, lab=True) then code-server won't open and Jupyter lab also not opening.

Can you suggest any way?

Thanks

can't be use on colab

I don't know why, but the ngrok not showing the codeserver. It said "Tunnel 7d647a92dxxx.ngrok.io not found". But it still work at kaggle notebook.

It is taking for ever to load the ngrok link for vs code server

I have an account in ngrok and I am also signed in ngrok website and as well as in the google colab. but after entering the authentication token a link by ngrok for the vs code server showed up, but after clicking it, its taking for ever for loading. I have a good internet connection but still this thing is happening.
And if anybody can help me with saving the installed extensions by me, every time I run the server for vs code. Then it would be very helpful.

Thank you

Python debugging doesn't work in ColabCode (or in ngrok?)

I'm using amazing ColabCode by Abhishek Thakur. It uses ngrok as backbone. But when I try to debug Python script (via F5 button), it doesn't launch any debug action even when I set a breakpoint. Script runs in terminal only. launch.json is empty. When I fill it with next:

"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}

]
I've got next error:

Couldn't find a debug adapter descriptor for debug type 'python' (extension might have failed to activate)

How can I debug Python script on ngrok code-server?

VS code doesn't open a new window?

whenever i call plt.imshow() along with it when i call plt.show() it shows output which is shown in the attached screenshot.

nw1

is there any solution to this?

colabcode JupyterLab doesn't display JupyterDash.run_server()

I opened colabcode JupyterLab with

import colabcode as cc
cc.ColabCode(port = 10000,  lab = True , authtoken=authtoken, mount_drive=True)

and run the code below.

from jupyter_dash import JupyterDash
import dash_html_components as html
app = JupyterDash(__name__)
app.layout = html.Div('Minimal')
app.run_server(mode='external')

It does show the sentence Dash app running on: followed by nothing without any error.

I run the same code on the JupyterLab with a local venv and it works.
Is there any way to solve this?

does this works on standard Juypter Notebooks

Hi @abhishekkrthakur
Learned this trick of running VSCODE in colab, from your LinkedIN post, great stuff.

I have a question, is there a way to run vscode in standard Juypter Notebook (non Colab ?). In our company we have hosted Juypter service, where we as data scientist can span juypter. I wanted to run VSCODE from those juypter notebooks.

So wanted to ask if this tool will also work on Juypter Notebooks.

Support cloudflare access

We know that colab instance can mostly be in these regions "AMS / SEA / LAX / TPE" and ngrok support us, ap, jp, eu regions. If we use cloudflare access, with anycast, we can connect to the nearest tunnel.

Colab disconnecting in an hour

I am using ColabCode from the last 3, 4 months and I have never encountered the problem with colab disconnecting while I was writing code. Recently, Colab is getting disconnecting within an hour after I run colabcode even when I am writing the code. Can anyone help me with this.
I am using Colab Pro.

Running into Error(500)

error vscode [UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character
error vscode Error: [UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character
at /usr/lib/code-server/lib/vscode/out/vs/server/entry.js:124:875
at new u (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:125:166)
at new d (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:126:773)
at Function.from (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:126:213)
at n (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:546:1003)
at t.Vscode.initialize (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:547:174)
at async process. (/usr/lib/code-server/lib/vscode/out/vs/server/entry.js:553:517)
[2021-04-09T19:50:18.382Z] error VS Code exited unexpectedly with code 1

Cloning repositories and connection to GitHub repository

Hi, @abhishekkrthakur, @ahtyamovdanil, @Skander-hadjromdhan !
First of all thanks for your package, I found it very useful!
Unfortunately, I have some problems with cloning GitHub repositories.

I tried to clone repo in VSCode via official instructions and then VSCode asked me to authorise in my account by this message
image

After clicking Continue I faced with this:
image

I already tried do SAME steps of authorising in my desktop VSCode and it was successful.
Is it possible to work with git via your package? Maybe I've done something wrong...

Thank you

P.S.
I followed all instructions in Abhishek's video

Ngrok Tunnel shows blank screen

Hello,

I have a new problem I have not encountered before with Colabcode and I hope to find help here. I am running
from google.colab import drive
drive.mount('/content/drive')

!pip install colabcode
from colabcode import ColabCode
ColabCode(port=10000)

in Colab and usually was able to access the Colab VSCode environment with an Ngrok tunnel there (2 weeks ago), however since yesterday it shows a blank screen. The output of the Colab cell is the same as before. Only difference is I get prompted to restart the runtime after which the output is the same as before when it ran smoothly.
Colabcode 0.2.0 was used but same problem persists with colabcode 0.1.0

Code Server can be accessed on: NgrokTunnel: "http://(id).ngrok.io" -> "http://localhost:10000"
[2021-02-04T09:28:44.663Z] info code-server 3.7.4 (id)
[2021-02-04T09:28:44.664Z] info Using user-data-dir ~/.local/share/code-server
[2021-02-04T09:28:44.673Z] info Using config file ~/.config/code-server/config.yaml
[2021-02-04T09:28:44.673Z] info HTTP server listening on http://127.0.0.1:10000
[2021-02-04T09:28:44.673Z] info - Authentication is disabled
[2021-02-04T09:28:44.673Z] info - Not serving HTTPS

Does anyone have any idea what the problem could be? Would appreciate any help, many thanks

What if we eliminate ngrok ?

Issue

Ngrok can be slow, ideally it's better to use it with the region parameter.

What if ...

As far as I know, I think there's a way on google colab to serve the code server on a URL (HTTPS). This URL is generate by google colab. This might has a huge impact on performance.

Would you like me to look into it and create a pull request if it's possible ?

Gpu acceleration not working

Hi Abhishek,

I hope you are fine. I don't know if you are aware of, or if it's just a bug for me, but when a add GPU acceleration to Kaggle or Colab notebooks it no longer works. I think google restricted their use but am not sure.

Are you aware of that it's not possible to have a GPU ?
Do you know a workaround to still use GPU ?

It's so convenient to use vs-code. Thank you in advance.

Can we run Docker on colabcode ?

I tried to run Docker on Colabcode terminal but It showed error "cannot connect to the docker daemon at unix:/var/run/docker.sock. is the docker daemon running colab" ? It seems like we can not run Docker on Google Colab , am I right ? Thank you very much

Python Extension not working for colabcode-0.1.0

Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)
versions:

  • colabcode-0.1.0
  • pyngrok-5.0.0
  • code-server 3.7.1 2bf91ff6a6d1f29a8a93f97684177ccf5388cf34
  • ms-python v2020.11.367453362

This could also be an issue of the code server 3.7.1 there have been lots of issues on it.
so maybe being able to specify the code server version could be a solution...?

unable to use code-server

I have been using this regularly since yesterday it says the password is wrong every time.
(using the password I set in colabcode initialization)

code-server debug problem

I can use terminal in vscode-server to run my python file ,but I wanna try to debug my py file ,it failed.
did anyone succeed to debug on vscode-server?

I keep getting this error

Too Many Connections
Too many connections! The tunnel session 'ts_1uRbFxBjU6WBQdMADOpMnFpA5mZ' has violated the rate-limit policy of 20 connections per minute by initiating 31 connections in the last 60 seconds. Please decrease your inbound connection volume or upgrade to a paid plan for additional capacity.

The error encountered was: ERR_NGROK_702

VSCode handshake timeout error

First of all, this library is simply amazing.

Lately, I've been facing an issue where the when I try to use VScode on GoogleColab using colabcode, it disconnects and the connection is terminated on GoogleColab.

Here is the screenshot of the error:
image

Any resolution on this issue will be higly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.