Skip to content

Commit

Permalink
Chore: Format code using Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jan 17, 2025
1 parent 8201b4d commit 78cf6e7
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 52 deletions.
11 changes: 9 additions & 2 deletions cratedb_toolkit/api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from click import ClickException
from click_aliases import ClickAliasedGroup

from cratedb_toolkit.options import option_cluster_id, option_cluster_name, option_sqlalchemy_url, option_http_url
from cratedb_toolkit.options import option_cluster_id, option_cluster_name, option_http_url, option_sqlalchemy_url
from cratedb_toolkit.util.cli import boot_click


Expand All @@ -18,7 +18,14 @@ def make_cli():
@click.version_option()
@click.pass_context
def cli(
ctx: click.Context, cratedb_sqlalchemy_url: str, cratedb_http_url: str, verbose: bool, debug: bool, scrub: bool
ctx: click.Context,
cluster_id: str,
cluster_name: str,
cratedb_sqlalchemy_url: str,
cratedb_http_url: str,
verbose: bool,
debug: bool,
scrub: bool,
):
"""
Diagnostics and informational utilities.
Expand Down
13 changes: 4 additions & 9 deletions cratedb_toolkit/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import sys
import time
import typing as t
from pathlib import Path

from boltons.urlutils import URL
from functools import lru_cache
from pathlib import Path

import click
from boltons.urlutils import URL

from cratedb_toolkit.api.guide import GuidingTexts
from cratedb_toolkit.api.model import ClientBundle, ClusterBase
Expand Down Expand Up @@ -333,9 +332,7 @@ class StandaloneCluster(ClusterBase):
address: DatabaseAddress
info: t.Optional[ClusterInformation] = None

def load_table(
self, source: InputOutputResource, target: TableAddress, transformation: t.Union[Path, None] = None
):
def load_table(self, source: InputOutputResource, target: TableAddress, transformation: t.Union[Path, None] = None):
"""
Load data into a database table on a standalone CrateDB Server.
Expand All @@ -360,9 +357,7 @@ def load_table(
return False

elif (
source_url_obj.scheme.startswith("influxdb")
or source_url.endswith(".lp")
or source_url.endswith(".lp.gz")
source_url_obj.scheme.startswith("influxdb") or source_url.endswith(".lp") or source_url.endswith(".lp.gz")
):
from cratedb_toolkit.io.influxdb import influxdb_copy

Expand Down
1 change: 0 additions & 1 deletion cratedb_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from .query.cli import cli as query_cli
from .shell.cli import cli as shell_cli
from .util.setting import init_dotenv
from .wtf.cli import cli as wtf_cli


@click.group(cls=ClickAliasedGroup) # type: ignore[arg-type]
Expand Down
2 changes: 1 addition & 1 deletion cratedb_toolkit/cluster/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from click_aliases import ClickAliasedGroup

from cratedb_toolkit import ManagedCluster
from cratedb_toolkit.options import option_cluster_id, option_cluster_name
from cratedb_toolkit.cluster.model import ClusterInformation
from cratedb_toolkit.exception import CroudException
from cratedb_toolkit.options import option_cluster_id, option_cluster_name
from cratedb_toolkit.util import jd
from cratedb_toolkit.util.cli import boot_click, make_command

Expand Down
2 changes: 1 addition & 1 deletion cratedb_toolkit/shell/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from cratedb_toolkit.cluster.model import ClusterInformation
from cratedb_toolkit.model import DatabaseAddress
from cratedb_toolkit.options import option_cluster_id, option_cluster_name, option_sqlalchemy_url
from cratedb_toolkit.cluster.model import ClusterInformation
from cratedb_toolkit.util.cli import boot_click
from cratedb_toolkit.util.crash import get_crash_output_formats, run_crash

Expand Down
2 changes: 1 addition & 1 deletion doc/info/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ctk cfr --cratedb-http-url "https://username:password@localhost:4200/?schema=ext
ctk cfr --cratedb-sqlalchemy-url "crate://username:password@localhost:4200/?schema=ext&ssl=true" jobstats collect
```

Define CrateDB database cluster address per aa. Choose one of both alternatives.
Define CrateDB database cluster address per environment variable. Choose one of both alternatives.
```shell
export CRATEDB_HTTP_URL=https://username:password@localhost:4200/?schema=ext
```
Expand Down
72 changes: 36 additions & 36 deletions examples/notebook/cloud_import.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# CrateDB Cloud Import\n",
"\n",
Expand All @@ -20,24 +23,24 @@
"## Setup\n",
"\n",
"To install the client SDK, use `pip`."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#!pip install 'cratedb-toolkit'"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## Configuration\n",
"\n",
Expand All @@ -56,13 +59,13 @@
"CRATEDB_USERNAME='admin'\n",
"CRATEDB_PASSWORD='H3IgNXNvQBJM3CiElOiVHuSp6CjXMCiQYhB4I9dLccVHGvvvitPSYr1vTpt4'\n",
"```"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## Acquire Database Cluster\n",
"\n",
Expand All @@ -71,10 +74,7 @@
"\n",
"For effortless configuration, it will obtain configuration settings from\n",
"environment variables as defined above."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
Expand All @@ -84,13 +84,16 @@
},
"outputs": [],
"source": [
"from cratedb_toolkit import ManagedCluster, InputOutputResource\n",
"from cratedb_toolkit import InputOutputResource, ManagedCluster\n",
"\n",
"cluster = ManagedCluster.from_env().start()"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## Import Data\n",
"\n",
Expand All @@ -105,22 +108,22 @@
"\n",
"[NAB Data Corpus]: https://github.com/numenta/NAB/tree/master/data\n",
"[MLflow and CrateDB]: https://github.com/crate/cratedb-examples/tree/main/topic/machine-learning/mlops-mlflow"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[36m==> Info: \u001B[0mStatus: REGISTERED (Your import job was received and is pending processing.)\n",
"\u001B[36m==> Info: \u001B[0mDone importing 22.70K records\n",
"\u001B[32m==> Success: \u001B[0mOperation completed.\n"
"\u001b[36m==> Info: \u001b[0mStatus: REGISTERED (Your import job was received and is pending processing.)\n",
"\u001b[36m==> Info: \u001b[0mDone importing 22.70K records\n",
"\u001b[32m==> Success: \u001b[0mOperation completed.\n"
]
},
{
Expand All @@ -140,26 +143,26 @@
"# Invoke import job. Without `target` argument, the destination\n",
"# table name will be derived from the input file name.\n",
"cluster.load_table(source=source)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## Query Data\n",
"\n",
"In order to inspect if the dataset has been imported successfully, run an SQL\n",
"command sampling a few records."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
Expand All @@ -173,10 +176,7 @@
"source": [
"# Query data.\n",
"cluster.query('SELECT * FROM \"nab-machine-failure\" LIMIT 5;')"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions examples/python/cloud_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
fall back to probe the environment variables.
"""

import json
import logging
import sys
Expand Down
2 changes: 1 addition & 1 deletion tests/io/mongodb/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import pytest

from tests.conftest import check_sqlalchemy2
from cratedb_toolkit.testing.testcontainers.util import PytestTestcontainerAdapter
from tests.conftest import check_sqlalchemy2

logger = logging.getLogger(__name__)

Expand Down

0 comments on commit 78cf6e7

Please sign in to comment.