Skip to content

Commit

Permalink
Packaging: Use cloud extra to install relevant packages
Browse files Browse the repository at this point in the history
I.e., don't always install the `croud` package.
  • Loading branch information
amotl committed Jan 19, 2024
1 parent 6343c73 commit 18d8367
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


## Unreleased
- Packaging: Use `cloud` extra to install relevant packages


## 2024/12/18 v0.0.3
Expand Down
2 changes: 1 addition & 1 deletion cratedb_toolkit/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from cratedb_toolkit.api.guide import GuidingTexts
from cratedb_toolkit.cluster.util import get_cluster_info
from cratedb_toolkit.exception import CroudException, OperationFailed
from cratedb_toolkit.io.croud import CloudIo
from cratedb_toolkit.model import ClusterInformation, DatabaseAddress, InputOutputResource, TableAddress

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -44,6 +43,7 @@ def load_table(self, resource: InputOutputResource, target: t.Optional[TableAddr
https://console.cratedb.cloud
"""
from cratedb_toolkit.io.croud import CloudIo

Check warning on line 46 in cratedb_toolkit/api/main.py

View check run for this annotation

Codecov / codecov/patch

cratedb_toolkit/api/main.py#L46

Added line #L46 was not covered by tests

target = target or TableAddress()

Expand Down
10 changes: 7 additions & 3 deletions cratedb_toolkit/cluster/util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from cratedb_toolkit.cluster.croud import CloudCluster
from cratedb_toolkit.model import ClusterInformation


def get_cluster_info(cluster_id: str) -> ClusterInformation:
cluster_info = ClusterInformation()
cc = CloudCluster(cluster_id=cluster_id)
cluster_info.cloud = cc.get_info()
try:
from cratedb_toolkit.cluster.croud import CloudCluster

Check warning on line 7 in cratedb_toolkit/cluster/util.py

View check run for this annotation

Codecov / codecov/patch

cratedb_toolkit/cluster/util.py#L6-L7

Added lines #L6 - L7 were not covered by tests

cc = CloudCluster(cluster_id=cluster_id)
cluster_info.cloud = cc.get_info()
except ImportError:
pass

Check warning on line 12 in cratedb_toolkit/cluster/util.py

View check run for this annotation

Codecov / codecov/patch

cratedb_toolkit/cluster/util.py#L9-L12

Added lines #L9 - L12 were not covered by tests
return cluster_info
5 changes: 4 additions & 1 deletion cratedb_toolkit/job/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from cratedb_toolkit.job.croud import jobs_list
from cratedb_toolkit.util.croud import get_croud_output_formats

output_formats = get_croud_output_formats()
try:
output_formats = get_croud_output_formats()
except ImportError:
output_formats = ["UNKNOWN"]


@click.command(name="list-jobs")
Expand Down
7 changes: 5 additions & 2 deletions cratedb_toolkit/util/croud.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
from unittest.mock import patch

import yaml
from croud.parser import Argument

from cratedb_toolkit.exception import CroudException

if t.TYPE_CHECKING:
from croud.parser import Argument

Check warning on line 16 in cratedb_toolkit/util/croud.py

View check run for this annotation

Codecov / codecov/patch

cratedb_toolkit/util/croud.py#L16

Added line #L16 was not covered by tests


logger = logging.getLogger(__name__)


@dataclasses.dataclass
class CroudCall:
fun: t.Callable
specs: t.List[Argument]
specs: t.List["Argument"]
arguments: t.List[str]


Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,17 @@ dependencies = [
"colorlog",
"crash",
"crate[sqlalchemy]>=0.34",
"croud==1.10.0",
'importlib-metadata; python_version <= "3.7"',
"python-dotenv<2",
"sqlalchemy",
"sqlparse<0.5",
]
[project.optional-dependencies]
all = [
"cratedb-toolkit[influxdb,io,mongodb]",
"cratedb-toolkit[cloud,influxdb,io,mongodb]",
]
cloud = [
"croud==1.10.0",
]
develop = [
"black[jupyter]<24",
Expand Down Expand Up @@ -271,7 +273,7 @@ format = [
# Configure Ruff not to auto-fix (remove!):
# unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001).
{ cmd = "ruff --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 ." },
{ cmd = "pyproject-fmt pyproject.toml" },
{ cmd = "pyproject-fmt --keep-full-version pyproject.toml" },
]

lint = [
Expand Down

0 comments on commit 18d8367

Please sign in to comment.