Skip to content

Commit

Permalink
Python Wrapper: Documentation fixes (#7052)
Browse files Browse the repository at this point in the history
* Python Wrapper: Documentation fixes

* CR Fixes

* CR Fixes 2

* CR Fixes 3
  • Loading branch information
N-o-Z authored Nov 26, 2023
1 parent 21ad0d0 commit 13d58dd
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 33 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/publish-python-wrapper-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ jobs:
- name: Python Build and Make Package
run: make package-python-wrapper

- name: Publish Distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TESTPYPI_API_TOKEN }}
packages_dir: clients/python-wrapper/dist/
verbose: true
repository-url: https://test.pypi.org/legacy/

# TODO: Enable once we're ready for production
- name: Publish Distribution 📦 to PyPI
if: false
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
Expand Down
13 changes: 6 additions & 7 deletions clients/python-wrapper/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# lakefs-sdk-wrapper (Pre-release Alpha)
# lakeFS Python SDK (Pre-release Beta)

This is a wrapper package for the lakefs-sdk API, providing the following features:
1. Provide a simpler programming interface with less configuration
2. Behave closer to other related Python SDKs
3. Allow inferring identity from environment
4. Provide better abstractions for common, more complex operations (I/O, transactions, imports)
lakeFS Software Development Kit (SDK) for Python, provides developers with the following features:
1. Simpler programming interface with less configuration
2. Inferring identity from environment
3. Better abstractions for common, more complex operations (I/O, transactions, imports)

## Requirements.

Expand Down Expand Up @@ -67,7 +66,7 @@ See [testing documentation](https://github.com/treeverse/lakeFS/blob/master/clie

## Documentation

[lakeFS SDK Wrapper](http://pydocs-wrapper.lakefs.io/)
[lakeFS Python SDK](http://pydocs-lakefs.lakefs.io/)

## Author

Expand Down
2 changes: 1 addition & 1 deletion clients/python-wrapper/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'python-wrapper'
project = 'python-lakefs'
copyright = '2023, Treeverse'
author = 'Treeverse'

Expand Down
4 changes: 2 additions & 2 deletions clients/python-wrapper/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to lakeFS's SDK Wrapper Documentation!
==============================================
Welcome to lakeFS's Python SDK Library Documentation!
=====================================================

.. toctree::
:maxdepth: 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lakefs.object\_io module
lakefs.namedtuple module
========================

.. automodule:: lakefs.object_io
.. automodule:: lakefs.namedtuple
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion clients/python-wrapper/lakefs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Client:
def __init__(self, **kwargs):
self._conf = ClientConfig(**kwargs)
self._client = LakeFSClient(self._conf.configuration, header_name='X-Lakefs-Client',
header_value='python-wrapper')
header_value='python-lakefs')

@property
def config(self):
Expand Down
2 changes: 1 addition & 1 deletion clients/python-wrapper/lakefs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class ClientConfig:
"""
Configuration class for the SDK wrapper Client.
Configuration class for the SDK Client.
Instantiation will try to get authentication methods using the following chain:
1. Provided kwargs to __init__ func (should contain necessary credentials as defined in lakefs_sdk.Configuration)
2. Use LAKECTL_SERVER_ENDPOINT_URL, LAKECTL_ACCESS_KEY_ID and LAKECTL_ACCESS_SECRET_KEY if set
Expand Down
4 changes: 2 additions & 2 deletions clients/python-wrapper/lakefs/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class LakeFSException(Exception):
"""
Base exception for all SDK Wrapper exceptions
Base exception for all SDK exceptions
"""
status_code: int
reason: str
Expand Down Expand Up @@ -58,7 +58,7 @@ class ServerException(LakeFSException):

class UnsupportedOperationException(LakeFSException):
"""
Operation not supported by lakeFS server or SDK wrapper
Operation not supported by lakeFS server or SDK
"""


Expand Down
11 changes: 9 additions & 2 deletions clients/python-wrapper/lakefs/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def writable(self) -> bool:
def seek(self, offset: int, whence: int = 0) -> int:
"""
Move the object's reading position
:param offset: The offset from the beginning of the file
:param whence: Optional. The whence argument is optional and defaults to
os.SEEK_SET or 0 (absolute file positioning);
Expand All @@ -267,6 +268,7 @@ def seek(self, offset: int, whence: int = 0) -> int:
def read(self, n: int = None) -> str | bytes:
"""
Read object data
:param n: How many bytes to read. If read_bytes is None, will read from current position to end.
If current position + read_bytes > object size.
:return: The bytes read
Expand Down Expand Up @@ -355,6 +357,7 @@ def pre_sign(self) -> bool:
def pre_sign(self, value: bool) -> None:
"""
Set the pre_sign mode to value
:param value: The new value for pre_sign mode
"""
self._pre_sign = value
Expand All @@ -372,6 +375,7 @@ def flush(self) -> None:
def write(self, s: AnyStr) -> int:
"""
Write data to buffer
:param s: The data to write
:return: The number of bytes written to buffer
"""
Expand Down Expand Up @@ -545,9 +549,10 @@ def path(self) -> str:
def reader(self, mode: ReadModes = 'r', pre_sign: Optional[bool] = None) -> ObjectReader:
"""
Context manager which provide a file-descriptor like object that allow reading the given object
:param mode: Read mode - as supported by ReadModes
:param pre_sign: (Optional), enforce the pre_sign mode on the lakeFS server. If not set, will probe server for
information.
information.
:return: A Reader object
"""
return ObjectReader(self, mode=mode, pre_sign=pre_sign, client=self._client)
Expand Down Expand Up @@ -583,6 +588,7 @@ def exist_handler(e: LakeFSException):
def copy(self, destination_branch_id: str, destination_path: str) -> WriteableObject:
"""
Copy the object to a destination branch
:param destination_branch_id: The destination branch to copy the object to
:param destination_path: The path of the copied object in the destination branch
:return: The newly copied Object
Expand Down Expand Up @@ -620,7 +626,8 @@ def upload(self,
content_type: Optional[str] = None,
metadata: Optional[dict[str, str]] = None) -> WriteableObject:
"""
Creates a new object or overwrites an existing object
Upload a new object or overwrites an existing object
:param data: The contents of the object to write (can be bytes or string)
:param mode: Write mode:
'x' - Open for exclusive creation
Expand Down
2 changes: 1 addition & 1 deletion clients/python-wrapper/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

NAME = "lakefs"
VERSION = "0.1.0-alpha.5"
VERSION = "0.1.0-beta"
# To install the library, run the following
#
# python setup.py install
Expand Down
6 changes: 3 additions & 3 deletions clients/python-wrapper/tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Python SDK Wrapper System Tests
# Python SDK System Tests

This package consists of the integration tests for the python SDK wrapper.
Please make sure to add / modify tests whenever pushing new code to the SDK wrapper.
This package consists of the integration tests for the python SDK library.
Please make sure to add / modify tests whenever pushing new code to the SDK.

These tests can be run against a lakeFS instance with the following environment configuration:

Expand Down
6 changes: 6 additions & 0 deletions docs/integrations/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ redirect_from:

{% include toc_2-3.html %}


**Improved Python SDK** <span class="badge mr-1">New</span><span class="badge">beta</span>
Check-out the newly released [Python SDK library](https://pydocs-lakefs.lakefs.io/) - providing simpler interface and improved user experience!
*OR* continue reading for the current Python SDK.
{: .note }

There are two primary ways to work with lakeFS from Python:

* [Use Boto](#using-boto) to perform **object operations** through the lakeFS S3 gateway.
Expand Down

0 comments on commit 13d58dd

Please sign in to comment.