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

feat: Make open to spin-off UI server and to be used in CLI and notebook #1157

Merged
merged 64 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
38c9d0a
feat: Expose open as an alternative to quickstart to should spin-off …
glemaitre Jan 19, 2025
62ed537
iter
glemaitre Jan 19, 2025
adb1f6b
iter
glemaitre Jan 19, 2025
a435720
iter
glemaitre Jan 19, 2025
091b4ae
iter
glemaitre Jan 19, 2025
01a6bb4
iter
glemaitre Jan 19, 2025
8a75f10
iter
glemaitre Jan 19, 2025
92b70f6
iter
glemaitre Jan 19, 2025
c3deb5c
iter
glemaitre Jan 19, 2025
b456066
iter
glemaitre Jan 19, 2025
37b49c3
test
glemaitre Jan 19, 2025
f1745d1
more tests for _load
glemaitre Jan 19, 2025
354cfa8
coverage
glemaitre Jan 19, 2025
eaf8578
more extensive test
glemaitre Jan 19, 2025
c555dab
iter
glemaitre Jan 23, 2025
edaa1da
iter
glemaitre Jan 23, 2025
55d1985
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 23, 2025
637f70f
iter
glemaitre Jan 24, 2025
32f3e4f
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 24, 2025
19342f6
iter
glemaitre Jan 24, 2025
bd7d926
iter
glemaitre Jan 24, 2025
e616f79
iter
glemaitre Jan 24, 2025
d6e7c5b
iter
glemaitre Jan 24, 2025
c76a805
iter
glemaitre Jan 25, 2025
ae61dd7
iter
glemaitre Jan 25, 2025
154d342
iter
glemaitre Jan 25, 2025
b338420
iter
glemaitre Jan 25, 2025
a475110
iter
glemaitre Jan 25, 2025
06561b6
debug
glemaitre Jan 25, 2025
cd04ecf
debug
glemaitre Jan 25, 2025
7c7d0fb
debug
glemaitre Jan 25, 2025
b861d58
debug
glemaitre Jan 25, 2025
0b09039
debug
glemaitre Jan 25, 2025
a6b0978
debug
glemaitre Jan 25, 2025
4bdaf58
revert ci
glemaitre Jan 25, 2025
3076c0b
revert ci
glemaitre Jan 25, 2025
c0115d5
iter
glemaitre Jan 25, 2025
1e2d6c0
debug
glemaitre Jan 25, 2025
7ff4c6e
debug
glemaitre Jan 25, 2025
8ac56a4
iter
glemaitre Jan 25, 2025
15e0b21
iter
glemaitre Jan 25, 2025
f7ecb17
iter
glemaitre Jan 25, 2025
ad26eab
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 25, 2025
504f146
iter
glemaitre Jan 25, 2025
f104af6
iter
glemaitre Jan 25, 2025
c346533
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 27, 2025
fb76b81
iter
glemaitre Jan 27, 2025
616110f
do not launch server
glemaitre Jan 27, 2025
9cba8ee
iter
glemaitre Jan 27, 2025
8cd9915
more tests
glemaitre Jan 28, 2025
bb4485c
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 28, 2025
9da454c
iter
glemaitre Jan 28, 2025
a052ff1
test
glemaitre Jan 28, 2025
690250c
tests
glemaitre Jan 28, 2025
1284808
more tests
glemaitre Jan 28, 2025
fcc1591
iter
glemaitre Jan 28, 2025
1682aa4
remove launch
glemaitre Jan 28, 2025
a7f575a
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 29, 2025
e6dd52a
iter
glemaitre Jan 29, 2025
38f1c8d
iter
glemaitre Jan 29, 2025
2683f3e
iter
glemaitre Jan 29, 2025
602030f
test command line
glemaitre Jan 29, 2025
c217d51
update documentation
glemaitre Jan 30, 2025
e1cc277
Merge remote-tracking branch 'origin/main' into is/1002
glemaitre Jan 30, 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
5 changes: 5 additions & 0 deletions skore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies = [
"scikit-learn",
"skops",
"uvicorn",
"platformdirs",
"psutil",
]
classifiers = [
"Intended Audience :: Science/Research",
Expand Down Expand Up @@ -113,12 +115,15 @@ addopts = [
"--ignore=doc",
"--ignore=examples",
"--ignore=notebooks",
"--dist=loadscope",
]
doctest_optionflags = ["ELLIPSIS", "NORMALIZE_WHITESPACE"]

[tool.coverage.run]
branch = true
source = ["skore"]
concurrency = ["thread", "multiprocessing"]
parallel = true

[tool.coverage.report]
omit = ["*/externals/*", "src/*", "tests/*"]
Expand Down
3 changes: 2 additions & 1 deletion skore/src/skore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rich.console import Console
from rich.theme import Theme

from skore.project import Project
from skore.project import Project, open
from skore.sklearn import (
CrossValidationReport,
CrossValidationReporter,
Expand All @@ -20,6 +20,7 @@
"CrossValidationReport",
"EstimatorReport",
"Project",
"open",
"show_versions",
"train_test_split",
]
Expand Down
84 changes: 45 additions & 39 deletions skore/src/skore/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,67 @@
from importlib.metadata import version

from skore.cli.color_format import ColorArgumentParser
from skore.ui.launch import launch
from skore.project import open
from skore.project._launch import _kill_all_servers


def argumentparser():
"""Argument parser for the Skore CLI."""
parser = ColorArgumentParser(
prog="skore-ui",
description="Launch the skore UI on a defined skore project.",
)
def cli(args: list[str]):
"""CLI for Skore."""
parser = ColorArgumentParser(prog="skore-ui")

parser.add_argument(
"--version",
action="version",
version=f"%(prog)s {version('skore')}",
"--version", action="version", version=f"%(prog)s {version('skore')}"
)

parser.add_argument(
"project_name",
help="the name or path of the project to be created or opened",
)
subparsers = parser.add_subparsers(dest="subcommand")

parser.add_argument(
# open a skore project
parser_open = subparsers.add_parser(
"open", help="Open a skore project and start the UI"
)
parser_open.add_argument(
"project_path",
nargs="?",
help="the name or path of the project to be opened",
)
parser_open.add_argument(
"--serve",
action=argparse.BooleanOptionalAction,
help=("whether to serve the project (default: %(default)s)"),
default=True,
glemaitre marked this conversation as resolved.
Show resolved Hide resolved
)
parser_open.add_argument(
"--port",
type=int,
help="the port at which to bind the UI server (default: %(default)s)",
default=22140,
default=None,
)

parser.add_argument(
"--open-browser",
action=argparse.BooleanOptionalAction,
help=(
"whether to automatically open a browser tab showing the web UI "
"(default: %(default)s)"
),
default=True,
parser_open.add_argument(
"--verbose",
action="store_true",
help="increase logging verbosity",
)

parser.add_argument(
# kill all UI servers
parser_kill = subparsers.add_parser("kill", help="Kill all UI servers")
parser_kill.add_argument(
"--verbose",
action="store_true",
help="increase logging verbosity",
)

return parser


def cli(args: list[str]):
"""CLI for Skore."""
parser = argumentparser()
arguments = parser.parse_args(args)
parsed_args: argparse.Namespace = parser.parse_args(args)

launch(
project_name=arguments.project_name,
port=arguments.port,
open_browser=arguments.open_browser,
verbose=arguments.verbose,
)
if parsed_args.subcommand == "open":
open(
project_path=parsed_args.project_path,
if_exists="load",
serve=parsed_args.serve,
keep_alive=True,
port=parsed_args.port,
verbose=parsed_args.verbose,
)
elif parsed_args.subcommand == "kill":
_kill_all_servers(verbose=parsed_args.verbose)
else:
parser.print_help()
2 changes: 1 addition & 1 deletion skore/src/skore/cli/color_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def format_help(self):

# Color the subcommands in cyan
help_text = re.sub(
r"(?<=\s)(launch|create|quickstart)(?=\s+)",
r"(?<=\s)(create|open|kill)(?=\s+)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
r"(?<=\s)(create|open|kill)(?=\s+)",
r"(?<=\s)(open|kill)(?=\s+)",

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: create doesn't exist anymore.

r"[cyan bold]\1[/cyan bold]",
help_text,
)
Expand Down
4 changes: 4 additions & 0 deletions skore/src/skore/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ class ProjectCreationError(Exception):

class ProjectPermissionError(Exception):
"""Permissions in the directory do not allow creating a file."""


class ProjectLoadError(Exception):
"""Failed to load project."""
2 changes: 2 additions & 0 deletions skore/src/skore/project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Alias top level function and class of the project submodule."""

from ._open import open
from .project import Project

__all__ = [
"open",
"Project",
]
Loading