Skip to content

Commit

Permalink
feat: include jcloud cli (#5074)
Browse files Browse the repository at this point in the history
* feat: include jcloud cli

* style: fix overload and cli autocomplete

* chore: improve help message

* chore: try jina cli with modified jcloud

* chore: try jina cli with modified jcloud

* chore: add jcloud to silent print

* fix: fix requirements

* fix: fix requirements

* style: fix overload and cli autocomplete

* chore: update help message

* chore: update cli args dist

* chore: add jcloud

* style: fix overload and cli autocomplete

* chore: update docstring

* docs: update docs

* fix(cli): jina auth cli error

* style: fix overload and cli autocomplete

Co-authored-by: Jina Dev Bot <dev-bot@jina.ai>
Co-authored-by: Han Xiao <han.xiao@jina.ai>
  • Loading branch information
3 people committed Aug 18, 2022
1 parent 10c63db commit 6f87524
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 18 deletions.
11 changes: 10 additions & 1 deletion docs/fundamentals/jcloud/index.md
Expand Up @@ -20,7 +20,8 @@ At this point, Jina Cloud hosts all your Jina projects and offers computational/

## Basic
### Install

If you have {ref}`installed jina <swagger-ui>`, there is no need to install `jcloud` CLI. However, you still can
install the CLI individually:
```bash
pip install jcloud
jc -h
Expand All @@ -30,6 +31,14 @@ jc -h
In case `jc` is already occupied by another tool, please use `jcloud` instead. If your pip install doesn't register bash commands for you, you can run `python -m jcloud -h`.
```

```{important}
You can use the `jcloud` CLI in 2 ways:
* If you installed it with `jina`, all of its commands come under the `jina cloud` command. Try `jina cloud --help` for
more info.
* If you installed it individually, all of its commands come under the `jc` or `jcloud` executable.
For the rest of this section, we will be using `jc` command rather than `jina cloud`.
```

### Login

```bash
Expand Down
3 changes: 2 additions & 1 deletion extra-requirements.txt
Expand Up @@ -33,7 +33,8 @@ grpcio-health-checking>=1.46.0: core
pyyaml>=5.3.1: core
packaging>=20.0: core
docarray>=0.13.14: core
jina-hubble-sdk==0.12.4: core
jina-hubble-sdk>=0.13.0: core
jcloud>=0.0.35: core
uvloop: perf,standard,devel
prometheus_client: perf,standard,devel
fastapi>=0.76.0: standard,devel
Expand Down
23 changes: 17 additions & 6 deletions jina/parsers/__init__.py
Expand Up @@ -229,23 +229,34 @@ def get_main_parser():
)
)

from hubble.parsers import get_main_parser as get_hubble_parser

get_hubble_parser(
sp.add_parser(
'auth',
description='Login to Jina AI with your GitHub/Google/Email account',
formatter_class=_chf,
help='Login to Jina AI',
)
)

set_hub_parser(
sp.add_parser(
'hub',
help='Push/pull an Executor to/from Jina Hub',
help='Manage Executor on Jina Hub',
description='Push/Pull an Executor to/from Jina Hub',
formatter_class=_chf,
)
)

from hubble.parsers import get_main_parser as get_hubble_parser
from jcloud.parsers import get_main_parser as get_jcloud_parser

get_hubble_parser(
get_jcloud_parser(
sp.add_parser(
'auth',
description='Login to Jina AI with your GitHub/Google/Email account',
'cloud',
description='Manage Flows on Jina Cloud',
formatter_class=_chf,
help='Login to Jina AI',
help='Manage Flows on Jina Cloud',
)
)

Expand Down
3 changes: 2 additions & 1 deletion jina/resources/extra-requirements.txt
Expand Up @@ -33,7 +33,8 @@ grpcio-health-checking>=1.46.0: core
pyyaml>=5.3.1: core
packaging>=20.0: core
docarray>=0.13.14: core
jina-hubble-sdk==0.12.4: core
jina-hubble-sdk>=0.13.0: core
jcloud>=0.0.35: core
uvloop: perf,standard,devel
prometheus_client: perf,standard,devel
fastapi>=0.76.0: standard,devel
Expand Down
2 changes: 1 addition & 1 deletion jina_cli/__init__.py
Expand Up @@ -10,7 +10,7 @@ def _get_run_args(print_args: bool = True):

console = get_rich_console()

silent_print = {'help', 'hub', 'export', 'auth'}
silent_print = {'help', 'hub', 'export', 'auth', 'cloud'}

parser = get_main_parser()
if len(sys.argv) > 1:
Expand Down
10 changes: 10 additions & 0 deletions jina_cli/api.py
Expand Up @@ -220,3 +220,13 @@ def auth(args: 'Namespace'):
from hubble import api

getattr(api, args.auth_cli.replace('-', '_'))(args)


def cloud(args: 'Namespace'):
"""
Use jcloud (Jina Cloud) commands
:param args: arguments coming from the CLI.
"""
from jcloud import api

getattr(api, args.jc_cli.replace('-', '_'))(args)
38 changes: 30 additions & 8 deletions jina_cli/autocomplete.py
Expand Up @@ -10,8 +10,9 @@
'export',
'new',
'gateway',
'hub',
'auth',
'hub',
'cloud',
'help',
'pod',
'deployment',
Expand Down Expand Up @@ -150,6 +151,13 @@
'--retries',
'--floating',
],
'auth login': ['--help', '--force'],
'auth logout': ['--help'],
'auth token create': ['--help', '--expire'],
'auth token delete': ['--help'],
'auth token list': ['--help'],
'auth token': ['--help', 'create', 'delete', 'list'],
'auth': ['--help', 'login', 'logout', 'token'],
'hub new': [
'--help',
'--name',
Expand Down Expand Up @@ -183,13 +191,27 @@
'--force',
],
'hub': ['--help', 'new', 'push', 'pull'],
'auth login': ['--help', '--force'],
'auth logout': ['--help'],
'auth token create': ['--help', '--expire'],
'auth token delete': ['--help'],
'auth token list': ['--help'],
'auth token': ['--help', 'create', 'delete', 'list'],
'auth': ['--help', 'login', 'logout', 'token'],
'cloud login': ['--help'],
'cloud deploy': ['--help', '--name', '--workspace', '--env-file'],
'cloud list': ['--help', '--status'],
'cloud logs': ['--help', '--executor'],
'cloud status': ['--help'],
'cloud remove': ['--help'],
'cloud new': ['--help'],
'cloud survey': ['--help'],
'cloud': [
'--help',
'--version',
'--loglevel',
'login',
'deploy',
'list',
'logs',
'status',
'remove',
'new',
'survey',
],
'help': ['--help'],
'pod': [
'--help',
Expand Down

0 comments on commit 6f87524

Please sign in to comment.