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

Added Region for lower latency #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ $ ColabCode()
# - 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
# - region: us(default) - United States, eu - Europe, ap - Asia/Pacific, au - Australia, sa - South America, jp - Japan, in - India

$ ColabCode(port=10000, password="abhishek", mount_drive=True)

$ ColabCode(port=10000, password="abhishek", mount_drive=True, region="in")
```
## How to use it?
Colab starter notebook: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/abhishekkrthakur/colabcode/blob/master/colab_starter.ipynb)
Expand Down
5 changes: 4 additions & 1 deletion colabcode/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import nest_asyncio
import uvicorn
from pyngrok import ngrok
from pyngrok import ngrok, conf
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed



try:
Expand All @@ -26,13 +26,15 @@ def __init__(
password=None,
authtoken=None,
mount_drive=False,
region="us",
code=True,
lab=False,
):
self.port = port
self.password = password
self.authtoken = authtoken
self._mount = mount_drive
self.region = region
self._code = code
self._lab = lab
if self._lab:
Expand Down Expand Up @@ -60,6 +62,7 @@ def _install_extensions():
subprocess.run(["code-server", "--install-extension", f"{ext}"])

def _start_server(self):
conf.get_default().region = self.region
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please pass region in options here: url = ngrok.connect(addr=self.port, options={"bind_tls": True})

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried it out but it does not work by doing that. That's why I have used this method as mentioned in pyngrok docs (https://pyngrok.readthedocs.io/en/latest/#setting-the-region).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Sir, Could you please review this? I've tried the change you mention but it doesn't seem to work.

if self.authtoken:
ngrok.set_auth_token(self.authtoken)
active_tunnels = ngrok.get_tunnels()
Expand Down