Skip to content

app

Command-line-interface for project-operations in dapla-jupterlab.

build(path=typer.Argument(None, help='Project path'), verify_config=typer.Option(True, '--no-verify', help='Verify git configuration files. Use --no-verify to disable verification (defaults to True).', show_default=True), no_kernel=False)

:wrench: Create a virtual environment and corresponding Jupyter kernel. Runs in the current folder if no arguments are supplied.

Source code in ssb_project_cli/ssb_project/app.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
@app.command()
def build(
    path: t.Optional[Path] = typer.Argument(  # noqa: B008
        None,
        help="Project path",
    ),
    verify_config: bool = typer.Option(  # noqa: B008
        True,
        "--no-verify",
        help="Verify git configuration files. Use --no-verify to disable verification (defaults to True).",
        show_default=True,
    ),
    no_kernel: Annotated[
        bool,
        typer.Option(
            "--no-kernel",
            help="Do not install a kernel after the project is built (defaults to False).",
        ),
    ] = False,
) -> None:
    """:wrench:  Create a virtual environment and corresponding Jupyter kernel. Runs in the current folder if no arguments are supplied."""
    build_project(
        path,
        CURRENT_WORKING_DIRECTORY,
        STAT_TEMPLATE_REPO_URL,
        STAT_TEMPLATE_DEFAULT_REFERENCE,
        verify_config,
        handle_no_kernel_argument(no_kernel),
    )

clean(project_name=typer.Argument(..., help='The name of the project/kernel you want to delete.'))

:broom: Delete the kernel for the given project name.

Source code in ssb_project_cli/ssb_project/app.py
154
155
156
157
158
159
160
161
@app.command()
def clean(
    project_name: str = typer.Argument(  # noqa: B008
        ..., help="The name of the project/kernel you want to delete."
    )
) -> None:
    """:broom:  Delete the kernel for the given project name."""
    clean_project(project_name)

create(project_name=typer.Argument(..., help='Project name'), description=typer.Argument('', help='A short description of your project'), repo_privacy=typer.Argument(RepoPrivacy.internal, help='Visibility of the Github repo'), add_github=False, github_token='', verify_config=True, template_git_url=STAT_TEMPLATE_REPO_URL, checkout=None, name=None, email=None, no_kernel=False)

:sparkles: Create a project locally, and optionally on GitHub with the flag --github. The project will follow SSB's best practice for development.

Source code in ssb_project_cli/ssb_project/app.py
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@app.command()
def create(  # noqa: C901, S107
    project_name: str = typer.Argument(..., help="Project name"),  # noqa: B008
    description: str = typer.Argument(  # noqa: B008
        "", help="A short description of your project"
    ),
    repo_privacy: RepoPrivacy = typer.Argument(  # noqa: B008
        RepoPrivacy.internal, help="Visibility of the Github repo"
    ),
    add_github: Annotated[
        bool, typer.Option("--github", help="Create the repo on Github as well")
    ] = False,
    github_token: Annotated[
        str,
        typer.Option(
            help="Your Github Personal Access Token, follow these instructions to create one: https://manual.dapla.ssb.no/git-github.html#personal-access-token-pat"
        ),
    ] = "",
    verify_config: Annotated[
        bool,
        typer.Option(
            "--no-verify",
            help="Verify git configuration files. Use --no-verify to disable verification (defaults to True).",
        ),
    ] = True,
    template_git_url: Annotated[
        str, typer.Option(help="The Cookiecutter template URI.")
    ] = STAT_TEMPLATE_REPO_URL,
    checkout: Annotated[
        t.Optional[str],
        typer.Option(
            help="The git reference to check against. Supports branches, tags and commit hashes.",
        ),
    ] = None,
    name: Annotated[
        t.Optional[str], typer.Option("--name", help="Project author's full name.")
    ] = None,
    email: Annotated[
        t.Optional[str], typer.Option("--email", help="Project author's email.")
    ] = None,
    no_kernel: Annotated[
        bool,
        typer.Option(
            "--no-kernel",
            help="Do not create a kernel after the project is created (defaults to False).",
        ),
    ] = False,
) -> None:
    """:sparkles:  Create a project locally, and optionally on GitHub with the flag --github. The project will follow SSB's best practice for development."""
    if not checkout and template_git_url is STAT_TEMPLATE_REPO_URL:
        checkout = STAT_TEMPLATE_DEFAULT_REFERENCE

    create_project(
        project_name,
        description,
        repo_privacy,
        add_github,
        github_token,
        CURRENT_WORKING_DIRECTORY,
        HOME_PATH,
        GITHUB_ORG_NAME,
        template_git_url,
        checkout,
        name,
        email,
        verify_config,
        handle_no_kernel_argument(no_kernel),
    )

main()

Main function of ssb_project_cli.

Source code in ssb_project_cli/ssb_project/app.py
164
165
166
167
def main() -> None:
    """Main function of ssb_project_cli."""
    set_debug_logging()
    app(prog_name="ssb-project")  # pragma: no cover