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

PR: Add service to handle the remote filesystem #11

Merged
merged 25 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
83eaa29
feat: add backend for fsspec as a service
hlouzada Dec 30, 2024
5945ff1
fix: start all handlers path with extension name
hlouzada Dec 30, 2024
84f8c8f
fix: update jupyter extension name to fit with authentication
hlouzada Dec 30, 2024
4c66686
fix: auto delete left-over server info
hlouzada Dec 30, 2024
c737025
feat: add atomic writes, lock and message buffer on file websocket
hlouzada Jan 7, 2025
d3ccb9e
fix: handler errors properly and parse arguments
hlouzada Jan 8, 2025
ea17c83
fix: set path as uri and parse arguments separatedly
hlouzada Jan 8, 2025
18b3ff4
feat: handle binary and encodings
hlouzada Jan 8, 2025
b90f1df
fix: handle properly errors in fsspec service
hlouzada Jan 9, 2025
800d06e
fix: expand user and use glob for ls method
hlouzada Jan 9, 2025
bd9f48a
fix: handle opening errors and other message types
hlouzada Jan 9, 2025
547ea31
fix: extension handlers must inherit from JupyterHandler
hlouzada Jan 9, 2025
18cc27d
fix: handle rest erros like websocket
hlouzada Jan 14, 2025
d1ff3fb
feat: add copy operations to file service
hlouzada Jan 14, 2025
562c760
fix: handle file not found erros properly
hlouzada Jan 14, 2025
77e898f
feat: add orjson dependency
hlouzada Jan 16, 2025
8d51ee0
feat: bump version
hlouzada Jan 16, 2025
d72914a
fix: handle arguments in copy handler as the other handlers
hlouzada Jan 18, 2025
83bfb48
fix: get only destination path from file path regex dest
hlouzada Jan 18, 2025
904bb89
fix: refactor review changes
hlouzada Jan 21, 2025
c949573
fix: keep 1.0.0 version
hlouzada Jan 21, 2025
b77bdbf
ref: apply review suggetions
hlouzada Jan 21, 2025
a9a21d8
Apply suggestions from code review
hlouzada Jan 21, 2025
4599cda
Update spyder_remote_services/services/files/base.py
hlouzada Jan 21, 2025
bb76248
fix: decode json before parse and run method on handling messages
hlouzada Jan 22, 2025
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
2 changes: 1 addition & 1 deletion jupyter-config/spyder_remote_services.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"spyder_remote_services": true
"spyder-services": true
}
}
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [
"jupyter_server >=2.14.2,<3.0",
"jupyter_client >=8.6.2,<9.0",
"envs-manager <1.0.0",
"orjson >=3.10.12,<4.0",
]

[tool.setuptools.dynamic]
Expand Down
24 changes: 18 additions & 6 deletions spyder_remote_services/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ def _port_default(self):
def info_file(self):
return str(Path(self.runtime_dir) / self.spyder_server_info_file)

def write_server_info_file(self) -> None:
if os.path.exists(self.info_file):
def write_server_info_file(self, *, __pid_check=True) -> None:
info_file = Path(self.info_file)
if info_file.exists():
if __pid_check:
with info_file.open(mode="rb") as f:
info = json.load(f)

# Simple check whether that process is really still running
if ("pid" in info) and not check_pid(info["pid"]):
# If the process has died, try to delete its info file
with suppress(OSError):
info_file.unlink()
self.write_server_info_file(__pid_check=False)

raise FileExistsError(
f"Server info file {self.info_file} already exists."
"Muliple servers are not supported, please make sure"
Expand All @@ -64,12 +76,12 @@ def start(self):

# The runtime dir might not exist
if not runtime_dir.is_dir():
return None
return

conf_file = runtime_dir / SpyderServerApp.spyder_server_info_file

if not conf_file.exists():
return None
return

with conf_file.open(mode="rb") as f:
info = json.load(f)
Expand All @@ -88,7 +100,7 @@ class SpyderRemoteServices(ExtensionApp):
"""A simple jupyter server application."""

# The name of the extension.
name = "spyder_remote_services"
name = "spyder-services"

open_browser = False

Expand All @@ -100,7 +112,7 @@ class SpyderRemoteServices(ExtensionApp):

def initialize_handlers(self):
"""Initialize handlers."""
self.handlers.extend(handlers)
self.handlers.extend([(rf"/{self.name}{h[0]}", h[1]) for h in handlers])

def initialize(self):
super().initialize()
Expand Down
3 changes: 2 additions & 1 deletion spyder_remote_services/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from spyder_remote_services.services.envs_manager.handlers import handlers as envs_manager_handlers
from spyder_remote_services.services.files.handlers import handlers as files_handlers

handlers = envs_manager_handlers
handlers = envs_manager_handlers + files_handlers
Empty file.
Loading