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

Run isort in toolchain #560

Merged
merged 3 commits into from
Jul 29, 2023
Merged
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ clean-test-containers:

.PHONY: lint-and-type-check
lint-and-type-check:
isort --check superduperdb tests
black --check superduperdb tests
ruff check superduperdb tests
mypy superduperdb
Expand All @@ -22,6 +23,7 @@ test: test-containers

.PHONY: fix-and-test
fix-and-test: test-containers
isort superduperdb tests
black superduperdb tests
ruff check --fix superduperdb tests
mypy superduperdb
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ omit-covered-files = true
quiet = false
verbose = 0
whitelist-regex = []

[tool.isort]
profile = "black"
2 changes: 2 additions & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ interrogate==1.5.0
# via -r requirements-lint.in
ipython==8.12.2
# via -r requirements-docs.in
isort==5.12.0
# via -r requirements-lint.in
itsdangerous==2.1.2
# via
# flask
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-lint.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
black>=23.3
boto3-stubs>=1.26.154
interrogate>=1.5.0
isort>=5.12.0
mypy>=1.3.0
ruff>=0.0.267
types-pillow>=9.5.0.4
Expand Down
2 changes: 2 additions & 0 deletions requirements/requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ colorama==0.4.6
# via interrogate
interrogate==1.5.0
# via -r requirements-lint.in
isort==5.12.0
# via -r requirements-lint.in
libcst==1.0.1
# via monkeytype
monkeytype==23.3.0
Expand Down
6 changes: 4 additions & 2 deletions superduperdb/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import sys

import click

from .cli import app, config, docs, info # noqa: F401, E402
from .cli.serve import local_cluster, serve # noqa: F401, E402
import click
import sys


def run():
Expand Down
3 changes: 2 additions & 1 deletion superduperdb/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .. import ICON
from typer import Typer

from .. import ICON

__all__ = 'app', 'command'

CLI_NAME = 'superduperdb'
Expand Down
6 changes: 4 additions & 2 deletions superduperdb/cli/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from . import command
from superduperdb import CFG
from typer import Option

from superduperdb import CFG

from . import command


@command(help='Print all the SuperDuperDB configs as JSON')
def config(
Expand Down
9 changes: 6 additions & 3 deletions superduperdb/cli/docs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from . import command
import functools
import os

from typer import Option

from superduperdb import ROOT
from superduperdb.misc import run
from typer import Option
import functools

from . import command

DOCS = 'docs'
DOCS_ROOT = ROOT / DOCS
Expand Down
10 changes: 6 additions & 4 deletions superduperdb/cli/info.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from . import command
from pathlib import Path
from superduperdb import ROOT
from superduperdb.misc import run
import datetime
import json
import os
import platform
import socket
import sys
from pathlib import Path

from superduperdb import ROOT
from superduperdb.misc import run

from . import command

PYPROJECT = ROOT / 'pyproject.toml'

Expand Down
9 changes: 5 additions & 4 deletions superduperdb/cli/serve.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from . import command
import typing as t

from superduperdb import CFG
from superduperdb.cluster.dask_client import dask_client
from superduperdb.cluster.server import serve as _serve
from superduperdb.datalayer.base.build import build_datalayer
from superduperdb.datalayer.base.cdc import DatabaseWatcher
from superduperdb.datalayer.mongodb.query import Collection
from superduperdb.cluster.server import serve as _serve
from superduperdb.cluster.dask_client import dask_client
from superduperdb import CFG

from . import command


@command(help='Start server')
Expand Down
3 changes: 2 additions & 1 deletion superduperdb/cluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import click
import requests

from superduperdb.core.artifact_tree import (
get_artifacts,
replace_artifacts_with_dict,
load_artifacts,
replace_artifacts_with_dict,
)
from superduperdb.core.component import Component
from superduperdb.core.document import Document, dump_bsons, load_bson, load_bsons
Expand Down
2 changes: 1 addition & 1 deletion superduperdb/cluster/dask_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
import typing as t
import uuid

from dask import distributed

Expand Down
5 changes: 2 additions & 3 deletions superduperdb/cluster/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

from flask import Flask, jsonify, make_response, request

from superduperdb import CFG
from superduperdb.core.artifact_tree import (
get_artifacts,
load_artifacts_from_store,
replace_artifacts_with_dict,
)
from superduperdb import CFG
from superduperdb.misc.serialization import serializers

from superduperdb.core.document import load_bson, load_bsons
from superduperdb.core.serializable import Serializable
from superduperdb.datalayer.base.build import build_datalayer
from superduperdb.misc.serialization import serializers


def make_endpoints(app, db):
Expand Down
1 change: 1 addition & 0 deletions superduperdb/core/artifact.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing as t

import typing_extensions as te

from superduperdb.datalayer.base.artifacts import ArtifactStore
Expand Down
1 change: 1 addition & 0 deletions superduperdb/core/artifact_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from superduperdb.datalayer.base.artifacts import ArtifactStore
from superduperdb.misc.serialization import serializers
from superduperdb.misc.tree import tree_find, tree_rewrite

from .artifact import Artifact

"""
Expand Down
4 changes: 3 additions & 1 deletion superduperdb/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

# ruff: noqa: F821
from __future__ import annotations

import dataclasses as dc
import typing as t

from superduperdb.core.job import ComponentJob, Job
from superduperdb.core.serializable import Serializable
import dataclasses as dc

if t.TYPE_CHECKING:
from superduperdb.datalayer.base.datalayer import Datalayer
Expand Down
8 changes: 5 additions & 3 deletions superduperdb/core/dataset.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations
from overrides import override
from functools import cached_property

import dataclasses as dc
import numpy
import typing as t
from functools import cached_property

import numpy
from overrides import override

from superduperdb.core.artifact import Artifact
from superduperdb.core.component import Component
Expand Down
8 changes: 5 additions & 3 deletions superduperdb/core/document.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from superduperdb.core.encoder import Encodable
import bson
import superduperdb as s
import typing as t

import bson
from bson.objectid import ObjectId

import superduperdb as s
from superduperdb.core.encoder import Encodable

ContentType = t.Union[t.Dict, Encodable]
ItemType = t.Union[t.Dict[str, t.Any], Encodable, ObjectId]

Expand Down
7 changes: 4 additions & 3 deletions superduperdb/core/encoder.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from superduperdb.misc import dataclasses as dc
import dataclasses
import io
import pickle
import typing as t

from superduperdb.core.artifact import Artifact
from superduperdb.core.component import Component
from PIL.PngImagePlugin import PngImageFile
from torch import Tensor

from superduperdb.core.artifact import Artifact
from superduperdb.core.component import Component
from superduperdb.misc import dataclasses as dc

Decode = t.Callable[[bytes], t.Any]
Encode = t.Callable[[t.Any], bytes]

Expand Down
3 changes: 1 addition & 2 deletions superduperdb/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import typing as t
import uuid


from superduperdb.core.tasks import method_job, callable_job
from superduperdb.core.tasks import callable_job, method_job
from superduperdb.misc.configs import CFG


Expand Down
4 changes: 2 additions & 2 deletions superduperdb/core/metric.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import dataclasses as dc
import typing as t

from superduperdb.core.artifact import Artifact
from superduperdb.core.component import Component

import typing as t


@dc.dataclass
class Metric(Component):
Expand Down
3 changes: 2 additions & 1 deletion superduperdb/core/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

import dataclasses as dc
import inspect
import multiprocessing
Expand All @@ -12,7 +13,7 @@
from superduperdb.core.component import Component
from superduperdb.core.dataset import Dataset
from superduperdb.core.encoder import Encoder
from superduperdb.core.job import Job, ComponentJob
from superduperdb.core.job import ComponentJob, Job
from superduperdb.core.metric import Metric
from superduperdb.core.serializable import Serializable
from superduperdb.datalayer.base.query import Select
Expand Down
12 changes: 8 additions & 4 deletions superduperdb/core/task_workflow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations
from .job import Job, ComponentJob, FunctionJob
from functools import wraps
from networkx import DiGraph, ancestors

import dataclasses as dc
import typing as t
from functools import wraps

import networkx
from networkx import DiGraph, ancestors

import superduperdb as s
import typing as t

from .job import ComponentJob, FunctionJob, Job

if t.TYPE_CHECKING:
from superduperdb.datalayer.base.datalayer import Datalayer
Expand Down
5 changes: 2 additions & 3 deletions superduperdb/core/vector_index.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dataclasses as dc
import itertools
import typing as t
import dataclasses as dc
import superduperdb as s

from overrides import override

import superduperdb as s
from superduperdb.core.component import Component
from superduperdb.core.document import Document
from superduperdb.core.encoder import Encodable
Expand All @@ -14,7 +14,6 @@
from superduperdb.misc.special_dicts import MongoStyleDict
from superduperdb.vector_search.base import VectorCollectionConfig, VectorCollectionItem


T = t.TypeVar('T')


Expand Down
8 changes: 5 additions & 3 deletions superduperdb/core/watcher.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import dataclasses as dc
import typing as t

from overrides import override

from superduperdb.datalayer.base.datalayer import Datalayer
from superduperdb.datalayer.base.query import Select

from .component import Component
from .job import Job
from .model import Model
from superduperdb.datalayer.base.datalayer import Datalayer
from superduperdb.datalayer.base.query import Select
import dataclasses as dc


@dc.dataclass
Expand Down
4 changes: 2 additions & 2 deletions superduperdb/datalayer/base/artifacts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from abc import ABC, abstractmethod
import hashlib
import typing as t
from abc import ABC, abstractmethod

from superduperdb.misc.serialization import serializers, Info
from superduperdb.misc.serialization import Info, serializers


class ArtifactStore(ABC):
Expand Down
3 changes: 1 addition & 2 deletions superduperdb/datalayer/base/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from superduperdb.datalayer.mongodb.artifacts import MongoArtifactStore
from superduperdb.datalayer.mongodb.data_backend import MongoDataBackend
from superduperdb.datalayer.mongodb.metadata import MongoMetaDataStore
from superduperdb.misc import config
from superduperdb.vector_search.inmemory import InMemoryVectorDatabase
from superduperdb.vector_search.lancedb_client import LanceVectorIndex
from superduperdb.misc import config


data_backends = {'mongodb': MongoDataBackend}

Expand Down
9 changes: 5 additions & 4 deletions superduperdb/datalayer/base/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import inspect

import superduperdb as s
from superduperdb.cluster.dask_client import dask_client
from superduperdb.datalayer.base.backends import artifact_stores
from superduperdb.datalayer.base.backends import connections as default_connections
from superduperdb.datalayer.base.backends import (
data_backends,
metadata_stores,
artifact_stores,
vector_database_stores,
connections as default_connections,
)
from superduperdb.datalayer.base.datalayer import Datalayer
from superduperdb.cluster.dask_client import dask_client
import superduperdb as s


def build_vector_database(cfg):
Expand Down
Loading