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

docs: add cli docs #577

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CLI Documentation

::: mkdocs-argparse
:module: datachain.cli
:function: get_parser
5 changes: 5 additions & 0 deletions docs/css/mkdocstrings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media screen and (min-width: 76.25em) {
.md-header__topic {
display: none;
}
}
8 changes: 7 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_name: ''
site_name: 'DataChain Documentation'
site_url: https://docs.datachain.ai
site_description: Wrangle unstructured AI data at scale

Expand Down Expand Up @@ -62,6 +62,9 @@ theme:
icon: material/weather-night
name: Switch to system preference

extra_css:
- css/mkdocstrings.css

nav:
- Home: index.md
- API reference:
Expand All @@ -72,6 +75,8 @@ nav:
- references/udf.md
- references/torch.md
- references/sql.md
- CLI Documentation:
- cli/index.md
- DataChain Website: https://datachain.ai" target="_blank"

markdown_extensions:
Expand All @@ -81,6 +86,7 @@ markdown_extensions:
- def_list
- footnotes
- md_in_html
- mkdocs_argparse
- pymdownx.details
- pymdownx.highlight:
anchor_linenums: true
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies = [
docs = [
"mkdocs>=1.5.2",
"mkdocs-gen-files>=0.5.0",
"mkdocs-argparse>=0.0.1",
"mkdocs-material>=9.3.1",
"mkdocs-section-index>=0.3.6",
"mkdocstrings-python>=1.6.3",
Expand Down
19 changes: 18 additions & 1 deletion src/datachain/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,24 @@ def set_team(args: "Namespace"):
print(f"Set default team to '{args.team_name}' in {config.config_file()}")


def login(args: "Namespace"):
def login(args: "Namespace") -> int:
"""
Login to studio using the CLI.

This function is called when the user runs `datachain studio login`.
It will prompt the user to login to studio and save the token to the
config file.

Keyword Arguments:
name (str): The name of the token to save in the config file
hostname (str): The hostname of the studio server. Defaults to `https://studio.datachain.ai`
scopes (List[str]): The scopes to request from the user


Returns:
int: 0 on success, 1 on failure
"""

from dvc_studio_client.auth import StudioAuthError, get_access_token

config = Config().read().get("studio", {})
Expand Down