Skip to content

Commit

Permalink
#156: Fixed implementation of BucketPath.parent (#157)
Browse files Browse the repository at this point in the history
* #156: Fixed implementation of BucketPath.parent
* Prepare release 0.13.0
  • Loading branch information
ckunki authored Aug 8, 2024
1 parent dc24516 commit 1f0f53f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
2 changes: 2 additions & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 📝 Changes

* [unreleased](unreleased.md)
* [0.13.0](changes_0.13.0.md)
* [0.12.0](changes_0.12.0.md)
* [0.11.0](changes_0.11.0.md)
* [0.10.0](changes_0.10.0.md)
Expand All @@ -19,6 +20,7 @@
hidden:
---
unreleased
changes_0.13.0
changes_0.12.0
changes_0.11.0
changes_0.10.0
Expand Down
5 changes: 5 additions & 0 deletions doc/changes/changes_0.13.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 0.13.0 - 2024-08-07

## Bugfixes

* #156: Fixed implementation of BucketPath.parent
52 changes: 26 additions & 26 deletions doc/design/bucketpath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Problem Description
Users of the BucketFS file system need to use it in various diffrent contexts like, from the outside of the
DB interacting with bucketfs, from within the DB when accessing BucketFS paths from within UDFs.
Also common actions/tasks like listing a directory are pretty tedious when just interacting with
the BucketFS API due to the fact that it does not know the concept of directories. So in
order to simplify and streamline frequently used path operations and also provide a uniform
the BucketFS API due to the fact that it does not know the concept of directories. So in
order to simplify and streamline frequently used path operations and also provide a uniform
interface accross the actual system (local path, http, ...) behind the BucketFS path we need
to have an abstraction for the user.

Expand Down Expand Up @@ -38,7 +38,7 @@ Challenges with Current BucketFS Interactions
Proposed Solution
=================

To address the identified issues with BucketFS interactions, we propose adding an abstraction layer that simplifies and standardizes these interactions across different contexts and operations. This approach is based on the design of the `pathlib` module in the Python standard library, which abstracts filesystem access across operating systems.
To address the identified issues with BucketFS interactions, we propose adding an abstraction layer that simplifies and standardizes these interactions across different contexts and operations. This approach is based on the design of the `pathlib` module in the Python standard library, which abstracts filesystem access across operating systems.

Our proposed path abstraction layer will:

Expand Down Expand Up @@ -152,50 +152,50 @@ Pathlike
class Pathlike(Protocol):
@property
def name:
def name(self) -> str:
"""
A string representing the final path component, excluding the drive and root, if any.
"""
@property
def suffix:
def suffix(self) -> str:
"""
The file extension of the final component, if any.
"""
@property
def root:
def root(self) -> str:
"""
A string representing the root, if any.
"""
@property
def parent:
def parent(self) -> PathLike:
"""
The logical parent of this path.
"""
def as_uri():
def as_uri(self) -> str:
"""
Represent the path as a file URI. Can be used to reconstruct the location/path.
"""
def exists():
def exists(self) -> bool:
"""
Return True if the path points to an existing file or directory.
"""
def is_dir():
def is_dir(self) -> bool:
"""
Return True if the path points to a directory, False if it points to another kind of file.
"""
def is_file():
def is_file(self) -> bool:
"""
Return True if the path points to a regular file, False if it points to another kind of file.
"""
def read(chunk_size: int = 8192) -> Iterable[ByteString]:
def read(self, chunk_size: int = 8192) -> Iterable[ByteString]:
"""
Read the content of a the file behind this path.
Expand All @@ -212,9 +212,9 @@ Pathlike
FileNotFoundError: If the file does not exist.
"""
def write(data: ByteString | BinaryIO | Iterable[ByteString]):
def write(self, data: ByteString | BinaryIO | Iterable[ByteString]):
"""
Writes data to a this path.
Writes data to a this path.
After successfully writing to this path `exists` will yield true for this path.
If the file already existed it will be overwritten.
Expand All @@ -226,7 +226,7 @@ Pathlike
NotAFileError: if the pathlike object is not a file path.
"""
def rm():
def rm(self):
"""
Remove this file.
Expand All @@ -238,7 +238,7 @@ Pathlike
FileNotFoundError: If the file does not exist.
"""
def rmdir(recursive: bool = False):
def rmdir(self, recursive: bool = False):
"""
Removes this directory.
Expand All @@ -254,15 +254,15 @@ Pathlike
PermissionError: If recursive is false and the directory is not empty.
"""
def joinpath(*pathsegements) -> Pathlike:
def joinpath(self, *pathsegements) -> Pathlike:
"""
Calling this method is equivalent to combining the path with each of the given pathsegments in turn.
Returns:
A new pathlike object pointing the combined path.
"""
def walk() -> Tuple[Pathlike, List[str], List[str]]:
def walk(self) -> Tuple[Pathlike, List[str], List[str]]:
"""
Generate the file names in a directory tree by walking the tree either top-down or bottom-up.
Expand All @@ -274,7 +274,7 @@ Pathlike
A 3-tuple of (dirpath, dirnames, filenames).
"""
def iterdir() -> Generator[Pathlike, None, None]:
def iterdir(self) -> Generator[Pathlike, None, None]:
"""
When the path points to a directory, yield path objects of the directory contents.
Expand All @@ -286,7 +286,7 @@ Pathlike
"""
# Overload / for joining, see also joinpath or `pathlib.Path`.
def __truediv__():
def __truediv__(self, other):
"""
"""
Expand All @@ -310,7 +310,7 @@ Each backend must implement the ``as_uri`` method in a way that the location is
"""
Provides access to a bucket path served via http or https.
"""
# uri protocol specifies associated with this class
protocol = ['bfs', 'bfss']
Expand All @@ -322,7 +322,7 @@ Each backend must implement the ``as_uri`` method in a way that the location is
bucket: used for accssing and interacting with to the underlying bucket.
path: of the file within the bucket.
"""
# Pathlike functionalities
# ...
Expand Down Expand Up @@ -365,7 +365,7 @@ Each modifier:
"""
Modifies a pathlike object so it will be locked into a specified root.
"""
def __init__(self, path: Pathlike, chroot='/'):
"""
Create a new Chroot.
Expand Down Expand Up @@ -400,7 +400,7 @@ Each modifier:
Returns:
A path like object whith write proection.
"""
# Pathlike functionalities
# Note: Non readonly actions should throw an exception
# ...
Expand Down Expand Up @@ -445,7 +445,7 @@ Factory & Builders
A Pathlike object for the given uri.
"""
# type: LocalPath, BucketPath, Chroot ...
#
#
# Note: based on the uri the factory should assemble the apropriate Pathlike object.
# E.g.:
type = _determine_type(path)
Expand Down Expand Up @@ -494,4 +494,4 @@ Utilities
Returns:
A LocalPath (UdfPath) object.
"""
6 changes: 3 additions & 3 deletions exasol/bucketfs/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def root(self) -> str:
"""

@property
def parent(self) -> str:
def parent(self) -> PathLike:
"""
The logical parent of this path.
"""
Expand Down Expand Up @@ -289,8 +289,8 @@ def root(self) -> str:
return self._path.root

@property
def parent(self) -> str:
return self._path.parent.name
def parent(self) -> PathLike:
return BucketPath(self._path.parent, self._bucket_api)

def as_uri(self) -> str:
return self._path.as_uri()
Expand Down
2 changes: 1 addition & 1 deletion exasol/bucketfs/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# Do not edit this file manually!
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = 0
MINOR = 12
MINOR = 13
PATCH = 0
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages = [
{include = "exasol"},
{include = "exasol_bucketfs_utils_python"}
]
version = "0.12.0"
version = "0.13.0"
description = "BucketFS utilities for the Python programming language"

license = "MIT"
Expand Down

0 comments on commit 1f0f53f

Please sign in to comment.