Skip to content

Commit

Permalink
Reformat code with up-to-date black tool version (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Burmak authored Jan 29, 2024
1 parent 233a121 commit 1e11aca
Show file tree
Hide file tree
Showing 76 changed files with 85 additions and 9 deletions.
1 change: 1 addition & 0 deletions ch_backup/backup/deduplication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Data part deduplication.
"""

from collections import defaultdict
from copy import copy
from datetime import timedelta
Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backup metadata.
"""

from ch_backup.backup.metadata.access_control_metadata import AccessControlMetadata
from ch_backup.backup.metadata.backup_metadata import BackupMetadata, BackupState
from ch_backup.backup.metadata.cloud_storage_metadata import CloudStorageMetadata
Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/access_control_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Access control metadata.
"""

from dataclasses import dataclass, field
from typing import Any, Dict, List, Sequence

Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/backup_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backup metadata.
"""

import json
import socket
from datetime import datetime, timezone
Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/cloud_storage_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backup metadata for Cloud Storage.
"""

from typing import Any, Dict, List, Optional


Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common constants.
"""

from enum import Enum


Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/part_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backup metadata for ClickHouse data part.
"""

from types import SimpleNamespace
from typing import Optional, Sequence

Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup/metadata/table_metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backup metadata for ClickHouse table.
"""

from types import SimpleNamespace
from typing import List, Optional, Set

Expand Down
1 change: 1 addition & 0 deletions ch_backup/backup_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup context
"""

from ch_backup.backup.layout import BackupLayout
from ch_backup.backup.metadata import BackupMetadata
from ch_backup.backup.restore_context import RestoreContext
Expand Down
1 change: 1 addition & 0 deletions ch_backup/calculators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Auxiliary functions for calculation sizes of backped data blocks.
"""

import math
from pathlib import Path
from tarfile import BLOCKSIZE, LENGTH_NAME
Expand Down
7 changes: 4 additions & 3 deletions ch_backup/ch_backup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic
"""

from collections import defaultdict
from copy import copy
from datetime import timedelta
Expand Down Expand Up @@ -247,9 +248,9 @@ def restore(
"Cloud storage source bucket must be set if backup has data on S3 disks"
)

self._context.config[
"override_replica_name"
] = override_replica_name or self._context.config.get("override_replica_name")
self._context.config["override_replica_name"] = (
override_replica_name or self._context.config.get("override_replica_name")
)
self._context.config["force_non_replicated"] = (
force_non_replicated or self._context.config["force_non_replicated"]
)
Expand Down
6 changes: 3 additions & 3 deletions ch_backup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ def restore_command(
specified_tables: typing.List[TableMetadata] = _key_values_to_tables_metadata(
tables
)
specified_exclude_tables: typing.List[
TableMetadata
] = _key_values_to_tables_metadata(exclude_tables)
specified_exclude_tables: typing.List[TableMetadata] = (
_key_values_to_tables_metadata(exclude_tables)
)

sources = BackupSources.for_restore(access, data, schema, udf, nc, schema_only)
ch_backup.restore(
Expand Down
1 change: 1 addition & 0 deletions ch_backup/clickhouse/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
ClickHouse client.
"""

from typing import Any

import requests
Expand Down
8 changes: 5 additions & 3 deletions ch_backup/clickhouse/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,11 @@ def _make_table(self, record: dict) -> Table:
name=record["name"],
engine=record.get("engine", None),
disks=list(self._disks.values()),
data_paths=record.get("data_paths", None)
if "MergeTree" in record.get("engine", "")
else [],
data_paths=(
record.get("data_paths", None)
if "MergeTree" in record.get("engine", "")
else []
),
metadata_path=record.get("metadata_path", None),
create_statement=record["create_table_query"],
uuid=record.get("uuid", None),
Expand Down
1 change: 1 addition & 0 deletions ch_backup/clickhouse/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utilities for schema manipulation.
"""

import re

from ch_backup import logging
Expand Down
1 change: 1 addition & 0 deletions ch_backup/encryption/noop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Noop encryption module
"""

from ch_backup.encryption.base import BaseEncryption


Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/access.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic for access entities.
"""

import os
import re
import shutil
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic for databases
"""

from typing import Dict, Sequence

from ch_backup import logging
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/lock_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Lock manager logic
"""

import os
import socket
import sys
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/named_collections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic for named collections
"""

from typing import List

from ch_backup import logging
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic for tables
"""

import os
from collections import deque
from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/udf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Clickhouse backup logic for UDFs
"""

from typing import List

from ch_backup import logging
Expand Down
1 change: 1 addition & 0 deletions ch_backup/logic/upload_part_observer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Uploading part observer."""

import time
from typing import List

Expand Down
1 change: 1 addition & 0 deletions ch_backup/params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
ParamType declarations.
"""

import json
import re
import typing
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Stage runners.
"""

from ch_backup.storage.async_pipeline.base_pipeline.flat_map import thread_flat_map
from ch_backup.storage.async_pipeline.base_pipeline.input import thread_input
from ch_backup.storage.async_pipeline.base_pipeline.map import thread_map
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Bytes FIFO module.
"""

import io


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Class for executing callables on specified pool.
"""

from concurrent.futures import Executor, Future, as_completed
from dataclasses import dataclass
from typing import Any, Callable, Dict, Optional
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/base_pipeline/flat_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Flat map runner for stage.
"""

from dataclasses import dataclass
from functools import partial
from typing import Any, Callable, Iterable, Optional, Union
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/base_pipeline/handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Abstract base classes for stage handlers.
"""

from abc import ABC, abstractmethod
from typing import Any, Iterable, Optional

Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/base_pipeline/input.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Input runner for stage.
"""

from dataclasses import dataclass
from functools import partial
from typing import Any, Callable, Iterable, Optional, Union
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/base_pipeline/map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Map runner for stage.
"""

from dataclasses import dataclass
from functools import partial
from typing import Any, Callable, Iterable, Optional, Union
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Rate limiter module.
"""

import time
from typing import Callable

Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/pipeline_builder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Pipeline builder.
"""

from functools import reduce
from math import ceil
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/pipeline_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
New pipelines executor module.
"""

from concurrent.futures import ProcessPoolExecutor
from functools import partial
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/pipelines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Free functions that create and run pipelines. Can be started in multiprocessing pool.
"""

from pathlib import Path
from tarfile import BLOCKSIZE
from typing import Any, AnyStr, List, Sequence
Expand Down
1 change: 1 addition & 0 deletions ch_backup/storage/async_pipeline/stages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Stages package.
"""

from .encryption.decrypt_stage import DecryptStage
from .encryption.encrypt_stage import EncryptStage
from .filesystem.chunking_stage import ChunkingStage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Decrypting stage.
"""

from ch_backup.encryption import BaseEncryption
from ch_backup.storage.async_pipeline.base_pipeline.handler import Handler
from ch_backup.storage.async_pipeline.stages.types import StageType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Encrypting stage.
"""

from ch_backup.encryption import BaseEncryption
from ch_backup.storage.async_pipeline.base_pipeline.handler import Handler
from ch_backup.storage.async_pipeline.stages.types import StageType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Chunking stage.
"""

from typing import Iterator

from ch_backup.storage.async_pipeline.base_pipeline.bytes_fifo import BytesFIFO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Collecting data stage.
"""

from io import BytesIO

from ch_backup.storage.async_pipeline.base_pipeline.handler import Handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Read file stage.
"""

from pathlib import Path
from typing import BinaryIO, Iterable, Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Reading files to TAR stream stage.
"""

import tarfile
from pathlib import Path
from typing import Iterator, List
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Write file stage.
"""

from pathlib import Path
from typing import BinaryIO, Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Writing files from TAR stream stage.
"""

from enum import Enum
from pathlib import Path
from tarfile import BLOCKSIZE, ENCODING, GNUTYPE_LONGNAME, NUL, TarInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Deleting objects from storage stage.
"""

from typing import Sequence

from ch_backup.storage.async_pipeline.base_pipeline.handler import InputHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Downloading object from a storage stage.
"""

from typing import Iterable, Optional

from ch_backup.storage.async_pipeline.base_pipeline.handler import InputHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Multipart uploading to storage stage.
"""

from dataclasses import dataclass
from typing import Optional

Expand Down
Loading

0 comments on commit 1e11aca

Please sign in to comment.