Skip to content

Commit

Permalink
Add missing docstrings found by pydocstyle
Browse files Browse the repository at this point in the history
ruff does not find them. These were only discovered once
pydocstyle was fixed to scan the full code tree.
  • Loading branch information
timj committed Dec 15, 2023
1 parent e764a67 commit 51e4345
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/lsst/daf/butler/remote_butler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@


class RemoteButlerOptionsModel(_BaseModelCompat):
"""Model representing the remote server connection."""

url: AnyHttpUrl


class RemoteButlerConfigModel(_BaseModelCompat):
"""Configuration representing a remote butler."""

remote_butler: RemoteButlerOptionsModel
50 changes: 50 additions & 0 deletions python/lsst/daf/butler/remote_butler/_remote_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,56 @@


class RemoteButler(Butler):
"""A `Butler` that can be used to connect through a remote server.
Parameters
----------
config : `ButlerConfig`, `Config` or `str`, optional
Configuration. Anything acceptable to the `ButlerConfig` constructor.
If a directory path is given the configuration will be read from a
``butler.yaml`` file in that location. If `None` is given default
values will be used. If ``config`` contains "cls" key then its value is
used as a name of butler class and it must be a sub-class of this
class, otherwise `DirectButler` is instantiated.
collections : `str` or `~collections.abc.Iterable` [ `str` ], optional
An expression specifying the collections to be searched (in order) when
reading datasets.
This may be a `str` collection name or an iterable thereof.
See :ref:`daf_butler_collection_expressions` for more information.
These collections are not registered automatically and must be
manually registered before they are used by any method, but they may be
manually registered after the `Butler` is initialized.
run : `str`, optional
Name of the `~CollectionType.RUN` collection new datasets should be
inserted into. If ``collections`` is `None` and ``run`` is not `None`,
``collections`` will be set to ``[run]``. If not `None`, this
collection will automatically be registered. If this is not set (and
``writeable`` is not set either), a read-only butler will be created.
searchPaths : `list` of `str`, optional
Directory paths to search when calculating the full Butler
configuration. Not used if the supplied config is already a
`ButlerConfig`.
writeable : `bool`, optional
Explicitly sets whether the butler supports write operations. If not
provided, a read-write butler is created if any of ``run``, ``tags``,
or ``chains`` is non-empty.
inferDefaults : `bool`, optional
If `True` (default) infer default data ID values from the values
present in the datasets in ``collections``: if all collections have the
same value (or no value) for a governor dimension, that value will be
the default for that dimension. Nonexistent collections are ignored.
If a default value is provided explicitly for a governor dimension via
``**kwargs``, no default will be inferred for that dimension.
http_client : `httpx.Client` or `None`, optional
Client to use to connect to the server. This is generally only
necessary for test code.
access_token : `str` or `None`, optional
Explicit access token to use when connecting to the server. If not
given an attempt will be found to obtain one from the environment.
**kwargs : `Any`
Parameters that can be used to set defaults for governor dimensions.
"""

def __init__(
self,
# These parameters are inherited from the Butler() constructor
Expand Down
4 changes: 4 additions & 0 deletions python/lsst/daf/butler/remote_butler/server/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@

@dataclass(frozen=True)
class Config:
"""Simplified configuration for a client/server connection."""

config_uri: str
"""URI of the configuration."""


def get_config_from_env() -> Config:
"""Retrieve a configuration from the environment."""
config_uri = os.getenv("BUTLER_SERVER_CONFIG_URI")
if config_uri is None:
raise Exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ def _make_global_butler() -> DirectButler:


def factory_dependency() -> Factory:
"""Return factory dependency for injection into FastAPI."""
return Factory(butler=_make_global_butler())
8 changes: 8 additions & 0 deletions python/lsst/daf/butler/remote_butler/server/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@


class NotFoundException(HTTPException):
"""Exception corresponding to a 404 server error.
Parameters
----------
message : `str`, optional
Message to include in the exception.
"""

def __init__(self, message: str = "Not found"):
super().__init__(status_code=404, detail=message)
8 changes: 8 additions & 0 deletions python/lsst/daf/butler/remote_butler/server/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@


class Factory:
"""Class to provide a cached Butler instance.
Parameters
----------
butler : `DirectButler`
Butler to use.
"""

def __init__(self, *, butler: DirectButler):
self._butler = butler

Expand Down

0 comments on commit 51e4345

Please sign in to comment.