8000 add mock datasite cli by eelcovdw · Pull Request #87 · OpenMined/rds · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add mock datasite cli #87

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged
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
36 changes: 36 additions & 0 deletions src/syft_rds/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from typing import Optional

import typer
from loguru import logger
from syft_core import Client as SyftBoxClient
from syft_core import SyftClientConfig

from syft_rds.server.app import create_app

Expand All @@ -26,6 +28,40 @@ def server(
rds_app.run_forever()


@app.command()
def init_test_datasite(
email: str = typer.Option(..., help="Email address for the client"),
client_url: str = typer.Option(
"http://testserver:5000",
help="URL of the SyftBox client server. Not used when testing locally.",
),
data_dir: Path = typer.Option(..., help="Directory for client data"),
config_path: Path = typer.Option(..., help="Path to save the config file"),
overwrite: bool = typer.Option(False, help="Overwrite existing config if present"),
) -> None:
"""
Initialize a new SyftBox client config for a datasite.
"""
config_path = config_path.resolve()
data_dir = data_dir.resolve()

if config_path.exists() and not overwrite:
logger.warning(
f"Config file {config_path} already exists. Use --overwrite to replace."
)
typer.echo(f"Config file {config_path} already exists. No action taken.")
raise typer.Exit(code=0)

config = SyftClientConfig(
email=email,
client_url=client_url,
path=config_path,
data_dir=data_dir,
)
config.save()
typer.echo(f"Created new SyftBox client config at {config_path}")


@app.callback()
def callback():
# Empty command to enable subcommands
Expand Down
0