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

Bump version + CLI updates #29

Merged
merged 11 commits into from
Nov 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion datalayer_core/about/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Datalayer provides a command line tool allowing to list, create, terminate and open a console against
a remote kernel.

Read more on https://docs.datalayer.run
Read more on https://docs.datalayer.io
2 changes: 1 addition & 1 deletion datalayer_core/authn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
logger = logging.getLogger(__name__)


DATALAYER_RUN_URL = "https://oss.datalayer.run"
DATALAYER_RUN_URL = "https://prod1.datalayer.run"


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion datalayer_core/authn/apps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
from rich.console import Console
from rich.table import Table

def display_me(me: dict) -> None:
def display_me(me: dict, infos: dict) -> None:
"""Display a my profile."""
table = Table(title="Profile")
table.add_column("ID", style="magenta", no_wrap=True)
table.add_column("Handle", style="cyan", no_wrap=True)
table.add_column("First name", style="green", no_wrap=True)
table.add_column("Last name", style="green", no_wrap=True)
table.add_column("RUN URL", style="green", no_wrap=True)
table.add_row(
me["uid"],
me["handle_s"],
me["first_name_t"],
me["last_name_t"],
infos.get("run_url")
)
console = Console()
console.print(table)
5 changes: 4 additions & 1 deletion datalayer_core/authn/apps/whoamiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ def start(self):
"{}/api/iam/v1/whoami".format(self.run_url),
)
raw = response.json()
display_me(raw.get("profile", {}))
infos = {
"run_url": self.run_url,
}
display_me(raw.get("profile", {}), infos)
2 changes: 1 addition & 1 deletion datalayer_core/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DatalayerCLIBaseApp(DatalayerApp):
help="Datalayer RUN URL."
)
def _run_url_default(self):
return os.environ.get("DATALAYER_RUN_URL", "https://oss.datalayer.run")
return os.environ.get("DATALAYER_RUN_URL", "https://prod1.datalayer.run")

token = Unicode(
None,
Expand Down
4 changes: 3 additions & 1 deletion datalayer_core/cli/datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

from datalayer_core.cli.base import DatalayerCLIBaseApp

from datalayer_core.about.aboutapp import DatalayerAboutApp
from datalayer_core.authn.apps.loginapp import DatalayerLoginApp
from datalayer_core.authn.apps.logoutapp import DatalayerLogoutApp
from datalayer_core.authn.apps.whoamiapp import WhoamiApp
from datalayer_core.benchmarks.benchmarksapp import BenchmarksApp
from datalayer_core.about.aboutapp import DatalayerAboutApp
from datalayer_core.environments.environmentsapp import EnvironmentsApp
from datalayer_core.kernels.console.consoleapp import KernelsConsoleApp
from datalayer_core.kernels.kernelsapp import JupyterKernelsApp
from datalayer_core.web.webapp import DatalayerWebApp

Expand All @@ -32,6 +33,7 @@ class DatalayerCLI(DatalayerCLIBaseApp):
subcommands = {
"about": (DatalayerAboutApp, DatalayerAboutApp.description.splitlines()[0]),
"benchmarks": (BenchmarksApp, BenchmarksApp.description.splitlines()[0]),
"console": (KernelsConsoleApp, KernelsConsoleApp.description.splitlines()[0]),
"envs": (EnvironmentsApp, EnvironmentsApp.description.splitlines()[0]),
"kernels": (JupyterKernelsApp, JupyterKernelsApp.description.splitlines()[0]),
"login": (DatalayerLoginApp, DatalayerLoginApp.description.splitlines()[0]),
Expand Down
1 change: 1 addition & 0 deletions datalayer_core/environments/environmentsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class EnvironmentsApp(DatalayerCLIBaseApp):

subcommands = {
"list": (EnvironmentsListApp, EnvironmentsListApp.description.splitlines()[0]),
"ls": (EnvironmentsListApp, EnvironmentsListApp.description.splitlines()[0]),
}

def start(self):
Expand Down
13 changes: 8 additions & 5 deletions datalayer_core/environments/list/listapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ def start(self):
)
content = response.json()
table = new_env_table()
for environment in content.get("environments", []):
environments = content.get("environments", [])
for environment in environments:
add_env_to_table(table, environment)
console = Console()
console.print(table)
print("""
if (len(environments) > 0):
print(f"""
Create a kernel with e.g.

datalayer kernels create --given-name my-kernel --credits-limit 3 python-simple-env
""")
""")
for environment in environments:
print(f"datalayer kernels create --given-name my-kernel --credits-limit 3 {environment['name']}")
print()
2 changes: 1 addition & 1 deletion datalayer_core/kernels/console/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WSTerminalInteractiveShell(ZMQTerminalInteractiveShell):
@default("banner")
def _default_banner(self):
# FIXME
return "JupyterKernels console {version}\n\n{kernel_banner}"
return "Datalayer - Jupyter Kernel console {version}\n\n{kernel_banner}"

async def handle_external_iopub(self, loop=None):
while self.keep_running:
Expand Down
7 changes: 3 additions & 4 deletions datalayer_core/kernels/create/createapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def start(self):
available -= sum(map(lambda r: r["credits"], reservations))
self.credits_limit = max(0., available * 0.5)
self.log.warning(
"The kernel will be allowed to consumed half of your remaining credits; i.e. {:.2f}.".format(
"The kernel will be allowed to consumed half of your remaining credits: {:.2f} credit.".format(
self.credits_limit
)
)
Expand All @@ -75,11 +75,10 @@ def start(self):
self.log.warning("Credits reservation is not positive. Exiting…")
self.exit(1)
body["credits_limit"] = self.credits_limit
body["environment_name"] = environment_name

response = self._fetch(
"{}/api/jupyter/v1/environment/{}".format(
self.run_url, environment_name
),
"{}/api/jupyter/v1/kernels".format(self.run_url),
method="POST",
json=body,
)
Expand Down
1 change: 1 addition & 0 deletions datalayer_core/kernels/kernelsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class JupyterKernelsApp(DatalayerCLIBaseApp):
"create": (KernelsCreateApp, KernelsCreateApp.description.splitlines()[0]),
"exec": (KernelsExecApp, KernelsExecApp.description.splitlines()[0]),
"list": (KernelsListApp, KernelsListApp.description.splitlines()[0]),
"ls": (KernelsListApp, KernelsListApp.description.splitlines()[0]),
"pause": (KernelsPauseApp, KernelsPauseApp.description.splitlines()[0]),
"start": (KernelsStartApp, KernelsStartApp.description.splitlines()[0]),
"stop": (KernelsStopApp, KernelsStopApp.description.splitlines()[0]),
Expand Down
5 changes: 0 additions & 5 deletions datalayer_core/kernels/list/listapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,3 @@ def start(self):
)
raw = response.json()
display_kernels(raw.get("kernels", []))
print("""
Create a kernel with e.g.

datalayer kernels create --given-name my-kernel --credits-limit 3 python-simple-env
""")
2 changes: 1 addition & 1 deletion datalayer_core/kernels/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def start_kernel(self, **kwargs):
kernel = None
if kernel_name:
response = fetch(
"{}/api/jupyter/v1/kernel/{}".format(self.run_url, kernel_name),
"{}/api/jupyter/v1/kernels/{}".format(self.run_url, kernel_name),
token=self.token,
)
kernel = response.json().get("kernel")
Expand Down
2 changes: 1 addition & 1 deletion datalayer_core/kernels/terminate/terminateapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def start(self):
kernel_id = self.extra_args[0]

self._fetch(
"{}/api/jupyter/v1/kernel/{}".format(self.run_url, kernel_id),
"{}/api/jupyter/v1/kernels/{}".format(self.run_url, kernel_id),
method="DELETE",
)
self.log.info(f"Kernel '{kernel_id}' deleted.")
2 changes: 1 addition & 1 deletion datalayer_core/serverapplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DatalayerExtensionApp(ExtensionAppJinjaMixin, ExtensionApp):
# In that case, the consumer of those settings are free
# to consider run_url as null.
run_url = Unicode(
"https://oss.datalayer.run",
"https://prod1.datalayer.run",
config=True,
allow_none=True,
help="""URL to connect to the Datalayer RUN APIs.""",
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@datalayer/core",
"version": "1.0.12",
"version": "1.0.23",
"description": "Ξ Datalayer Core.",
"keywords": [
"datalayer",
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"homepage": "https://github.com/datalayer/datalayer",
"homepage": "https://github.com/datalayer/core",
"bugs": {
"url": "https://github.com/datalayer/datalayer/issues"
},
Expand All @@ -27,7 +27,7 @@
"style": "style/index.css",
"repository": {
"type": "git",
"url": "https://github.com/datalayer/datalayer.git"
"url": "https://github.com/datalayer/datalayer_core.git"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev",
Expand Down Expand Up @@ -65,7 +65,7 @@
"watch:src": "tsc -w"
},
"dependencies": {
"@datalayer/ui": "^0.2.8"
"@datalayer/ui": "^0.3.9"
},
"devDependencies": {
"@babel/core": "^7.21.0",
Expand Down Expand Up @@ -179,6 +179,7 @@
"@lumino/signaling": "2.1.1",
"@lumino/virtualdom": "2.0.1",
"@lumino/widgets": "2.3.1",
"@lezer/python": "1.1.13",
"@primer/react": "^36.25.0",
"@rjsf/core": "5.3.0",
"@rjsf/utils": "5.3.0",
Expand Down Expand Up @@ -266,7 +267,7 @@
"singleton": true
},
"@jupyterlite/pyodide-kernel": {
"bundled": false,
"bundled": true,
"singleton": true
},
"@jupyterlite/server": {
Expand Down
4 changes: 2 additions & 2 deletions src/DatalayerApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { useState, useEffect } from 'react';
import { createRoot } from 'react-dom/client';
import { MemoryRouter } from 'react-router-dom';
import { RunIndex, LoginFormCLI, BenchmarksExample, KernelsExample } from '@datalayer/ui';
import { IOIndex, LoginFormCLI, BenchmarksExample, KernelsExample } from '@datalayer/ui';

import '../style/index.css';

Expand Down Expand Up @@ -48,7 +48,7 @@ export const DatalayerApp = (): JSX.Element => {
<></>
)}
{ view === 'web' && (
<RunIndex />
<IOIndex />
)}
{ view === 'kernels' && (
<KernelsExample memoryRouter={true} baseRoute="datalayer" />
Expand Down
Loading