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

[Feature] Added User Data Config #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions colabcode/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@


class ColabCode:
def __init__(self, port=10000, password=None, mount_drive=False):
def __init__(self, port=10000, password=None, user_data_dir=None, mount_drive=False):
self.port = port
self.password = password
self.user_data_dir = user_data_dir
self._mount = mount_drive
self._install_code()
self._install_extensions()
Expand Down Expand Up @@ -45,8 +46,12 @@ def _run_code(self):
os.system(f"fuser -n tcp -k {self.port}")
if self._mount and colab_env:
drive.mount("/content/drive")
if self.password:
if self.password and self.user_data_dir:
code_cmd = f"PASSWORD={self.password} code-server --port {self.port} --user-data-dir {self.user_data_dir} --disable-telemetry"
elif self.password:
code_cmd = f"PASSWORD={self.password} code-server --port {self.port} --disable-telemetry"
elif self.user_data_dir:
code_cmd = f"code-server --port {self.port} --auth none --user-data-dir {self.user_data_dir} --disable-telemetry"
else:
code_cmd = f"code-server --port {self.port} --auth none --disable-telemetry"
with subprocess.Popen(
Expand Down