-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI and JupyterLab plugins for IAM and Kernels (#21)
* chore: activate all plugins * chore: add iam and kernels * chore: working cli * chore: cli app * fix: exec * chore: rename to datalayer_core * chore: license * chore: rm jupyterlab from deps * chore: revert to datalayer * chore: revert to datalayer extensions * lint * chore: set version
- Loading branch information
Showing
72 changed files
with
3,455 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
header: | ||
license: | ||
spdx-id: Datalayer | ||
copyright-owner: Datalayer, Inc. | ||
copyright-year: 2023-2024 | ||
content: | | ||
Copyright (c) [year] [owner] | ||
Distributed under the terms of the Modified BSD License. | ||
paths-ignore: | ||
- '**/*.apt' | ||
- '**/*.cedar' | ||
- '**/*.dash' | ||
- '**/*.fga' | ||
- '**/*.ipynb' | ||
- '**/*.j2' | ||
- '**/*.json' | ||
- '**/*.mamba' | ||
- '**/*.md' | ||
- '**/*.mod' | ||
- '**/*.nblink' | ||
- '**/*.rego' | ||
- '**/*.sum' | ||
- '**/*.svg' | ||
- '**/*.template' | ||
- '**/*.tsbuildinfo' | ||
- '**/*.txt' | ||
- '**/*.yaml' | ||
- '**/*.yml' | ||
- '**/*_key' | ||
- '**/*_key.pub' | ||
- '**/.*' | ||
- '**/LICENSE.txt' | ||
- '**/MANIFEST.in' | ||
- '**/build' | ||
- '**/lib' | ||
- '**/node_modules' | ||
- '**/schemas' | ||
- '**/ssh/*' | ||
- '**/static' | ||
- '**/themes' | ||
- '**/typings' | ||
- '**/*.patch' | ||
- '**/*.bundle.js' | ||
- '**/*.map.js' | ||
- 'LICENSE' | ||
|
||
comment: on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"""The main for Datalayer.""" | ||
|
||
from datalayer.serverapplication import main | ||
from datalayer_core.serverapplication import main | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file is auto-generated by Hatchling. As such, do not: | ||
# - modify | ||
# - track in version control e.g. be sure to add to .gitignore | ||
__version__ = VERSION = '1.1.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## About | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Datalayer Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from pathlib import Path | ||
|
||
from datalayer_core.application import NoStart | ||
from rich.console import Console | ||
from rich.markdown import Markdown | ||
|
||
from datalayer_core.cli.base import DatalayerCLIBaseApp | ||
|
||
|
||
HERE = Path(__file__).parent | ||
|
||
|
||
class DatalayerAboutApp(DatalayerCLIBaseApp): | ||
"""Kernel About application.""" | ||
|
||
description = """ | ||
An application to print useful information | ||
about jupyter kernels. | ||
""" | ||
|
||
_requires_auth = False | ||
|
||
|
||
def start(self): | ||
try: | ||
super().start() | ||
console = Console() | ||
with open(HERE / "about.md") as readme: | ||
markdown = Markdown(readme.read()) | ||
console.print(markdown) | ||
except NoStart: | ||
pass | ||
self.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) Datalayer Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from __future__ import annotations | ||
|
||
import logging | ||
|
||
from datalayer_core.authn.http_server import get_token | ||
|
||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
KERNELS_URL = "https://oss.datalayer.run" | ||
|
||
|
||
if __name__ == "__main__": | ||
from sys import argv | ||
|
||
if len(argv) == 2: | ||
ans = get_token(KERNELS_URL, port=int(argv[1])) | ||
else: | ||
ans = get_token(KERNELS_URL) | ||
|
||
if ans is not None: | ||
handle, token = ans | ||
else: | ||
handle = None | ||
token = None | ||
|
||
logger.info(f"Logged as {handle} with token: {token}") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) Datalayer Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import warnings | ||
|
||
from datalayer_core.cli.base import DatalayerCLIBaseApp | ||
|
||
|
||
class DatalayerLoginApp(DatalayerCLIBaseApp): | ||
"""An application to log into a remote kernel provider.""" | ||
|
||
description = """ | ||
An application to log into a remote kernel provider. | ||
jupyter kernels login | ||
""" | ||
|
||
def start(self): | ||
"""Start the app.""" | ||
if len(self.extra_args) > 0: # pragma: no cover | ||
warnings.warn("Too many arguments were provided for login.") | ||
self.print_help() | ||
self.exit(1) | ||
|
||
if self.token and self.user_handle: | ||
self.log.info(f"🎉 Successfully authenticated as {self.user_handle} on {self.kernels_url}") | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Datalayer Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import warnings | ||
|
||
from datalayer_core.cli.base import DatalayerCLIBaseApp | ||
|
||
|
||
class DatalayerLogoutApp(DatalayerCLIBaseApp): | ||
"""An application to logout of a remote kernel provider.""" | ||
|
||
description = """ | ||
An application to logout of a remote kernel provider. | ||
jupyter kernels logout | ||
""" | ||
|
||
_requires_auth = False | ||
|
||
|
||
def start(self): | ||
"""Start the app.""" | ||
if len(self.extra_args) > 0: # pragma: no cover | ||
warnings.warn("Too many arguments were provided for logout.") | ||
self.print_help() | ||
self.exit(1) | ||
""" | ||
FIXME | ||
self._fetch( | ||
"{}/api/iam/v1/logout".format(self.kernels_url), | ||
) | ||
""" | ||
|
||
self._log_out() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) Datalayer Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import warnings | ||
|
||
from datalayer_core.cli.base import DatalayerCLIBaseApp | ||
from ...kernels.utils import display_me | ||
|
||
|
||
class KernelWhoamiApp(DatalayerCLIBaseApp): | ||
"""An application to list the kernels.""" | ||
|
||
description = """ | ||
An application to list the kernels. | ||
jupyter kernels list | ||
""" | ||
|
||
def start(self): | ||
"""Start the app.""" | ||
if len(self.extra_args) > 0: # pragma: no cover | ||
warnings.warn("Too many arguments were provided for kernel list.") | ||
self.print_help() | ||
self.exit(1) | ||
|
||
response = self._fetch( | ||
"{}/api/iam/v1/whoami".format(self.kernels_url), | ||
) | ||
raw = response.json() | ||
display_me(raw.get("profile", {})) |
Oops, something went wrong.