Skip to content

Commit

Permalink
WIP: draft bucketpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti committed Mar 14, 2024
1 parent 08e4864 commit 1d702b5
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
157 changes: 157 additions & 0 deletions doc/design/bucketpath.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
==============================
Design Document Bucket Path(s)
==============================

Introduction
============

- Purpose of the document / Problem description
- Definitions and Acronyms

Overview
========

Design Goals
============

Path Design
===========

Future Considerations
=====================

Sudo Code Outline
=================

.. code-block:: python
from exasol.bucketfs import PathBuilder
Path = PathBuilder(credentials)
udf_path = Path("bfsl://some/local/path/file.tar.gz")
http_bucket_path = Path("bfs://127.0.0.1:8888/service/bucket/some/file.tar.gz")
https_bucket_path = Path("bfss://127.0.0.1:8888/service/bucket/some/file.tar.gz")
chroot_path = Path("bfss://127.0.0.1:8888/service/bucket/some/sub/subsub/file.tar.gz?chroot=/some/sub/")
.. code-block:: python
from typing import Protocol
# interface / protocol or abc
# Note: should mimic pathlib.Path so it can easily understood and adopted.
class Pathlike(Protocol):
@property
def name:
...
@property
def suffix:
...
@property
def root:
...
def as_uri():
...
def exists():
...
def is_dir():
...
def is_file():
...
def read_text():
...
def read_bytes():
...
def write_text():
...
def write_bytes():
...
def unlink():
...
def rmdir():
...
def join()
...
def walk():
...
def iterdir():
...
# overload / for joining
def __truediv__():
...
# Note: needs to support Pathlike
class BucketPath:
protocol = ['bfs', 'bfss']
def __init__(bucket: Bucket, path):
...
# QUESTION: UdfPath? Do we need to distuinguish between localpaths and localpaths within udf?
# Note: needs to support Pathlike
class LocalPath:
protocol = ['bfsl']
def __init__(path):
...
# Note: needs to support Pathlike
# restrict a path to use a specific root, instead of the "normal" root
# this shall and should work on every Pathlike
class Chroot:
# does not have a protocol, works on all kinds.
# if ?chroot is part of the uri the path LocalPath/BucketPath needs
# to be additionaly wrapped into a Chroot
def __init__(self, path: Pathlike, chroot='/'):
pass
def PathBuilder:
def __init__(*args, **kwargs):
"""
Pass credentails/crendentails store etc.
"""
pass
def __call__(path, chroot='/') -> Pathlike:
# type: LocalPath, BucketPath, Chroot
type = _determine_type(path)
facories = {
"udf" = _create_udf_path,
"bfs" = _create_bucket_path,
"chroot" = _create_chroot_path,
}
factory = factory[type]
return factory(args)
7 changes: 7 additions & 0 deletions doc/design/design.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
📑 Design Documents
===================

.. toctree::
:maxdepth: 1

bucketpath
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
user_guide/user_guide
api
developer_guide/developer_guide
design/design
changes/changelog

0 comments on commit 1d702b5

Please sign in to comment.