Skip to content

Commit

Permalink
Merge branch 'migrate_from_quirk_docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwardrop committed Apr 3, 2024
2 parents a04cc65 + cee9063 commit 98c66e1
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions omniduct/caches/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas
import yaml
from decorator import decorator
from interface_meta import quirk_docs
from interface_meta import inherit_docs

from omniduct.duct import Duct
from omniduct.utils.config import config
Expand Down Expand Up @@ -134,7 +134,7 @@ class Cache(Duct):

DUCT_TYPE = Duct.Type.CACHE

@quirk_docs("_init", mro=True)
@inherit_docs("_init", mro=True)
def __init__(self, **kwargs): # pylint: disable=super-init-not-called
Duct.__init_with_kwargs__(self, kwargs)
self._init(**kwargs)
Expand Down
24 changes: 12 additions & 12 deletions omniduct/databases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import jinja2.meta
import sqlparse
from decorator import decorator
from interface_meta import quirk_docs, override
from interface_meta import inherit_docs, override

from omniduct.caches.base import cached_method
from omniduct.duct import Duct
Expand Down Expand Up @@ -96,7 +96,7 @@ def NAMESPACE_DEFAULTS_WRITE(self):
"""
return self.NAMESPACE_DEFAULTS_READ

@quirk_docs("_init", mro=True)
@inherit_docs("_init", mro=True)
# pylint: disable-next=super-init-not-called
def __init__(
self,
Expand Down Expand Up @@ -268,7 +268,7 @@ def statement_cleanup(cls, statement):
"session_properties": kwargs["session_properties"],
},
)
@quirk_docs("_execute")
@inherit_docs("_execute")
@require_connection
def execute(
self, statement, wait=True, cursor=None, session_properties=None, **kwargs
Expand Down Expand Up @@ -710,7 +710,7 @@ def query_from_template(self, name, context=None, **kwargs):

# Uploading/querying data into data store
@logging_scope("Query [CTAS]", timed=True)
@quirk_docs("_query_to_table")
@inherit_docs("_query_to_table")
def query_to_table(self, statement, table, if_exists="fail", **kwargs):
"""
Run a query and store the results in a table in this database.
Expand All @@ -734,7 +734,7 @@ def query_to_table(self, statement, table, if_exists="fail", **kwargs):
return self._query_to_table(statement, table, if_exists=if_exists, **kwargs)

@logging_scope("Dataframe Upload", timed=True)
@quirk_docs("_dataframe_to_table")
@inherit_docs("_dataframe_to_table")
@require_connection
def dataframe_to_table(self, df, table, if_exists="fail", **kwargs):
"""
Expand Down Expand Up @@ -784,7 +784,7 @@ def _parse_namespaces(self, name, level=0, defaults=None, write=False):
),
)

@quirk_docs("_table_list")
@inherit_docs("_table_list")
def table_list(self, namespace=None, renew=True, **kwargs):
"""
Return a list of table names in the data source as a DataFrame.
Expand All @@ -806,7 +806,7 @@ def table_list(self, namespace=None, renew=True, **kwargs):
def _table_list(self, namespace, **kwargs):
pass

@quirk_docs("_table_exists")
@inherit_docs("_table_exists")
def table_exists(self, table, renew=True, **kwargs):
"""
Check whether a table exists.
Expand All @@ -828,7 +828,7 @@ def table_exists(self, table, renew=True, **kwargs):
def _table_exists(self, table, **kwargs):
pass

@quirk_docs("_table_drop")
@inherit_docs("_table_drop")
def table_drop(self, table, **kwargs):
"""
Remove a table from the database.
Expand All @@ -848,7 +848,7 @@ def table_drop(self, table, **kwargs):
def _table_drop(self, table, **kwargs):
pass

@quirk_docs("_table_desc")
@inherit_docs("_table_desc")
def table_desc(self, table, renew=True, **kwargs):
"""
Describe a table in the database.
Expand All @@ -869,7 +869,7 @@ def table_desc(self, table, renew=True, **kwargs):
def _table_desc(self, table, **kwargs):
pass

@quirk_docs("_table_partition_cols")
@inherit_docs("_table_partition_cols")
def table_partition_cols(self, table, renew=True, **kwargs):
"""
Extract the columns by which a table is partitioned (if database supports partitions).
Expand All @@ -891,7 +891,7 @@ def _table_partition_cols(self, table, **kwargs):
f"Database backend `{self.__class__.__name__}` does not support, or has not implemented, support for extracting partition columns."
)

@quirk_docs("_table_head")
@inherit_docs("_table_head")
def table_head(self, table, n=10, renew=True, **kwargs):
"""
Retrieve the first `n` rows from a table.
Expand All @@ -915,7 +915,7 @@ def table_head(self, table, n=10, renew=True, **kwargs):
def _table_head(self, table, n=10, **kwargs):
pass

@quirk_docs("_table_props")
@inherit_docs("_table_props")
def table_props(self, table, renew=True, **kwargs):
"""
Retrieve the properties associated with a table.
Expand Down
10 changes: 5 additions & 5 deletions omniduct/duct.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from builtins import input
from enum import Enum

from interface_meta import InterfaceMeta, quirk_docs
from interface_meta import InterfaceMeta, inherit_docs

from omniduct.errors import DuctProtocolUnknown, DuctServerUnreachable
from omniduct.utils.debug import logger, logging_scope
Expand Down Expand Up @@ -261,7 +261,7 @@ def __setattr__(self, key, value):
pass
object.__setattr__(self, key, value)

@quirk_docs("_prepare")
@inherit_docs("_prepare")
def prepare(self):
"""
Prepare a Duct subclass for use (if not already prepared).
Expand Down Expand Up @@ -476,7 +476,7 @@ def __assert_server_reachable(self):

# Connection
@logging_scope("Connecting")
@quirk_docs("_connect")
@inherit_docs("_connect")
def connect(self):
"""
Connect to the service backing this client.
Expand Down Expand Up @@ -511,7 +511,7 @@ def connect(self):
def _connect(self):
raise NotImplementedError

@quirk_docs("_is_connected")
@inherit_docs("_is_connected")
def is_connected(self):
"""
Check whether this `Duct` instances is currently connected.
Expand Down Expand Up @@ -540,7 +540,7 @@ def is_connected(self):
def _is_connected(self):
raise NotImplementedError

@quirk_docs("_disconnect")
@inherit_docs("_disconnect")
def disconnect(self):
"""
Disconnect this client from backing service.
Expand Down
34 changes: 17 additions & 17 deletions omniduct/filesystems/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict, namedtuple

import pandas as pd
from interface_meta import quirk_docs, override
from interface_meta import inherit_docs, override

from omniduct.duct import Duct
from omniduct.utils.decorators import require_connection
Expand All @@ -23,7 +23,7 @@ class FileSystemClient(Duct, MagicsProvider):
DUCT_TYPE = Duct.Type.FILESYSTEM
DEFAULT_PORT = None

@quirk_docs("_init", mro=True)
@inherit_docs("_init", mro=True)
def __init__( # pylint: disable=super-init-not-called
self, cwd=None, home=None, read_only=False, global_writes=False, **kwargs
):
Expand Down Expand Up @@ -53,7 +53,7 @@ def _init(self):
# Path properties and helpers

@property
@quirk_docs("_path_home")
@inherit_docs("_path_home")
@require_connection
def path_home(self):
"""
Expand Down Expand Up @@ -96,7 +96,7 @@ def path_cwd(self, path_cwd):
self._path_cwd = path_cwd

@property
@quirk_docs("_path_separator")
@inherit_docs("_path_separator")
def path_separator(self):
"""
str: The character(s) to use in separating path components. Typically
Expand Down Expand Up @@ -248,7 +248,7 @@ def _assert_path_is_writable(self, path):

# Filesystem accessors

@quirk_docs("_exists")
@inherit_docs("_exists")
@require_connection
def exists(self, path):
"""
Expand All @@ -267,7 +267,7 @@ def exists(self, path):
def _exists(self, path):
raise NotImplementedError

@quirk_docs("_isdir")
@inherit_docs("_isdir")
@require_connection
def isdir(self, path):
"""
Expand All @@ -286,7 +286,7 @@ def isdir(self, path):
def _isdir(self, path):
raise NotImplementedError

@quirk_docs("_isfile")
@inherit_docs("_isfile")
@require_connection
def isfile(self, path):
"""
Expand All @@ -313,7 +313,7 @@ def _dir(self, path):
"""
raise NotImplementedError

@quirk_docs("_dir")
@inherit_docs("_dir")
@require_connection
def dir(self, path=None):
"""
Expand Down Expand Up @@ -386,7 +386,7 @@ def _showdir(self, path):
)
return "Directory has no contents."

@quirk_docs("_walk")
@inherit_docs("_walk")
@require_connection
def walk(self, path=None):
"""
Expand Down Expand Up @@ -423,7 +423,7 @@ def _walk(self, path):
): # Note: using _walk directly here, which may fail if disconnected during walk.
yield walked

@quirk_docs("_find")
@inherit_docs("_find")
@require_connection
def find(self, path_prefix=None, **attrs):
"""
Expand Down Expand Up @@ -475,7 +475,7 @@ def is_match(f):
): # Note: using _find directly here, which may fail if disconnected during find.
yield match

@quirk_docs("_mkdir")
@inherit_docs("_mkdir")
@require_connection
def mkdir(self, path, recursive=True, exist_ok=False):
"""
Expand All @@ -498,7 +498,7 @@ def mkdir(self, path, recursive=True, exist_ok=False):
def _mkdir(self, path, recursive, exist_ok):
raise NotImplementedError

@quirk_docs("_remove")
@inherit_docs("_remove")
@require_connection
def remove(self, path, recursive=False):
"""
Expand Down Expand Up @@ -527,7 +527,7 @@ def _remove(self, path, recursive):

# File handling

@quirk_docs("_open")
@inherit_docs("_open")
@require_connection
def open(self, path, mode="rt"):
"""
Expand All @@ -553,7 +553,7 @@ def open(self, path, mode="rt"):
def _open(self, path, mode):
return FileSystemFile(self, path, mode)

@quirk_docs("_file_read_")
@inherit_docs("_file_read_")
@require_connection
def _file_read(self, path, size=-1, offset=0, binary=False):
"""
Expand All @@ -577,7 +577,7 @@ def _file_read(self, path, size=-1, offset=0, binary=False):
def _file_read_(self, path, size=-1, offset=0, binary=False):
raise NotImplementedError

@quirk_docs("_file_write_")
@inherit_docs("_file_write_")
@require_connection
def _file_write(self, path, s, binary=False):
"""
Expand All @@ -599,7 +599,7 @@ def _file_write(self, path, s, binary=False):
def _file_write_(self, path, s, binary):
raise NotImplementedError

@quirk_docs("_file_append_")
@inherit_docs("_file_append_")
@require_connection
def _file_append(self, path, s, binary=False):
"""
Expand All @@ -623,7 +623,7 @@ def _file_append_(self, path, s, binary):

# File transfer

@quirk_docs("_download")
@inherit_docs("_download")
def download(self, source, dest=None, overwrite=False, fs=None):
"""
Download files to another filesystem.
Expand Down
12 changes: 6 additions & 6 deletions omniduct/remotes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from abc import abstractmethod

from interface_meta import quirk_docs, override
from interface_meta import inherit_docs, override

from omniduct.duct import Duct
from omniduct.errors import DuctAuthenticationError, DuctServerUnreachable
Expand Down Expand Up @@ -120,7 +120,7 @@ class RemoteClient(FileSystemClient):
DUCT_TYPE = Duct.Type.REMOTE
DEFAULT_PORT = None

@quirk_docs("_init", mro=True)
@inherit_docs("_init", mro=True)
def __init__(
self, smartcards=None, **kwargs
): # pylint: disable=super-init-not-called
Expand Down Expand Up @@ -217,7 +217,7 @@ def _prepare_smartcard(self, name, filename):

return True

@quirk_docs("_execute")
@inherit_docs("_execute")
@require_connection
def execute(self, cmd, **kwargs):
"""
Expand Down Expand Up @@ -264,7 +264,7 @@ def _extract_host_and_ports(self, remote_host, remote_port, local_port):
port = m.group("port") or remote_port
return host, port, local_port

@quirk_docs("_port_forward_start")
@inherit_docs("_port_forward_start")
@require_connection
def port_forward(self, remote_host, remote_port=None, local_port=None):
"""
Expand Down Expand Up @@ -354,7 +354,7 @@ def has_port_forward(self, remote_host=None, remote_port=None, local_port=None):
)
return self.__port_forwarding_register.reverse_lookup(local_port) is not None

@quirk_docs("_port_forward_stop")
@inherit_docs("_port_forward_stop")
def port_forward_stop(self, local_port=None, remote_host=None, remote_port=None):
"""
Disconnect an existing port forward connection.
Expand Down Expand Up @@ -447,7 +447,7 @@ def _port_forward_start(self, local_port, remote_host, remote_port):
def _port_forward_stop(self, local_port, remote_host, remote_port, connection):
raise NotImplementedError

@quirk_docs("_is_port_bound")
@inherit_docs("_is_port_bound")
@require_connection
def is_port_bound(self, host, port):
"""
Expand Down
4 changes: 2 additions & 2 deletions omniduct/restful/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from urllib.parse import urljoin

from interface_meta import quirk_docs, override
from interface_meta import inherit_docs, override

from omniduct.duct import Duct
from omniduct.utils.decorators import require_connection
Expand Down Expand Up @@ -29,7 +29,7 @@ class RestClientBase(Duct):

DUCT_TYPE = Duct.Type.RESTFUL

@quirk_docs("_init", mro=True)
@inherit_docs("_init", mro=True)
def __init__( # pylint: disable=super-init-not-called
self,
server_protocol="http",
Expand Down
Loading

0 comments on commit 98c66e1

Please sign in to comment.