pynessie package

Subpackages

Submodules

pynessie.cli module

Console script for nessie_client.

class pynessie.cli.ContextObject(nessie, verbose, json)[source]

Bases: object

Click context object.

json: bool
nessie: pynessie.nessie_client.NessieClient
verbose: bool
class pynessie.cli.DefaultHelp(*args, **kwargs)[source]

Bases: click.core.Command

If no options are presented show help.

parse_args(ctx, args)[source]

Ensure that help is shown if nothing else is selected.

Return type

List

class pynessie.cli.MutuallyExclusiveOption(*args, **kwargs)[source]

Bases: click.core.Option

Only allow one option in a list to be set at once.

handle_parse_result(ctx, opts, args)[source]

Ensure mutually exclusive options are not used together.

Return type

Tuple[Any, List[str]]

pynessie.error module

Nessie Exceptions.

exception pynessie.error.NessieConflictException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for conflict error 408.

exception pynessie.error.NessieException(msg, original_exception, response)[source]

Bases: Exception

Base Nessie exception.

json()[source]

Dump this exception as a json object.

Return type

str

exception pynessie.error.NessieNotFoundException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for not found error 404.

exception pynessie.error.NessiePermissionException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for permission error 403.

exception pynessie.error.NessiePreconidtionFailedException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for pre-condition failed error 412.

exception pynessie.error.NessieServerException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for server errors 5xx.

exception pynessie.error.NessieUnauthorizedException(msg, original_exception, response)[source]

Bases: pynessie.error.NessieException

Nessie exception for login error 401.

pynessie.error.error_handler(f)[source]

Wrap a click method to catch and pretty print errors.

Return type

Callable

pynessie.model module

Nessie Data objects.

class pynessie.model.Branch(name, hash_=None)[source]

Bases: pynessie.model.Reference

Dataclass for Nessie Branch.

hash_: Optional[str]
name: str
class pynessie.model.CommitMeta(hash_=None, commitTime=None, authorTime=None, committer=None, author=None, signedOffBy=None, message=None, properties=None)[source]

Bases: object

Dataclass for commit metadata.

author: str
authorTime: datetime.datetime
commitTime: datetime.datetime
committer: str
hash_: str
message: str
properties: dict
signedOffBy: str
class pynessie.model.Contents(id)[source]

Bases: object

Dataclass for Nessie Contents.

id: str
pretty_print()[source]

Print out for cli.

Return type

str

class pynessie.model.ContentsKey(elements)[source]

Bases: object

ContentsKey.

elements: List[str]
class pynessie.model.ContentsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow_oneofschema.one_of_schema.OneOfSchema

Schema for Nessie Content.

dump_fields: typing.Dict[str, ma_fields.Field]
fields: typing.Dict[str, ma_fields.Field]

Dictionary mapping field_names -> Field objects

get_obj_type(obj)[source]

Returns the object type based on its class.

Return type

str

load_fields: typing.Dict[str, ma_fields.Field]
opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
type_schemas = {'DELTA_LAKE_TABLE': <class 'marshmallow.schema.DeltaLakeTable'>, 'ICEBERG_TABLE': <class 'marshmallow.schema.IcebergTable'>, 'VIEW': <class 'marshmallow.schema.SqlView'>}
class pynessie.model.Delete(key)[source]

Bases: pynessie.model.Operation

Delete single key.

key: pynessie.model.ContentsKey
class pynessie.model.DeltaLakeTable(id, last_checkpoint, checkpoint_location_history, metadata_location_history)[source]

Bases: pynessie.model.Contents

Dataclass for Nessie Contents.

checkpoint_location_history: List[str]
id: str
last_checkpoint: str
metadata_location_history: List[str]
pretty_print()[source]

Print out for cli.

Return type

str

class pynessie.model.Entries(entries, has_more=False, token=None)[source]

Bases: object

Dataclass for Content Entries.

entries: List[pynessie.model.Entry]
has_more: bool
token: str
class pynessie.model.Entry(kind, name)[source]

Bases: object

Dataclass for Nessie Entry.

kind: str
name: pynessie.model.EntryName
class pynessie.model.EntryName(elements)[source]

Bases: object

Dataclass for Nessie Entry Name.

elements: List[str]
class pynessie.model.IcebergTable(id, metadata_location, snapshot_id)[source]

Bases: pynessie.model.Contents

Dataclass for Nessie Contents.

id: str
metadata_location: str
pretty_print()[source]

Print out for cli.

Return type

str

snapshot_id: int
class pynessie.model.LogResponse(operations, has_more=False, token=None)[source]

Bases: object

Dataclass for Log Response.

has_more: bool
operations: List[pynessie.model.CommitMeta]
token: str
class pynessie.model.Merge(from_ref_name, from_hash=None)[source]

Bases: object

Dataclass for Merge operation.

from_hash: str
from_ref_name: str
class pynessie.model.MultiContents(commit_meta, operations)[source]

Bases: object

Contents container for commit.

commit_meta: pynessie.model.CommitMeta
operations: List[pynessie.model.Operation]
class pynessie.model.Operation(key)[source]

Bases: object

Single Commit Operation.

key: pynessie.model.ContentsKey
class pynessie.model.OperationsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow_oneofschema.one_of_schema.OneOfSchema

Schema for Nessie Operations.

dump_fields: typing.Dict[str, ma_fields.Field]
fields: typing.Dict[str, ma_fields.Field]

Dictionary mapping field_names -> Field objects

get_obj_type(obj)[source]

Returns the object type based on its class.

Return type

str

load_fields: typing.Dict[str, ma_fields.Field]
opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
type_schemas = {'DELETE': <class 'marshmallow.schema.Delete'>, 'PUT': <class 'marshmallow.schema.Put'>, 'UNCHANGED': <class 'marshmallow.schema.Unchanged'>}
class pynessie.model.Put(key, contents)[source]

Bases: pynessie.model.Operation

Single Commit Operation.

contents: pynessie.model.Contents
key: pynessie.model.ContentsKey
class pynessie.model.Reference(name, hash_=None)[source]

Bases: object

Dataclass for Nessie Reference.

hash_: Optional[str]
name: str
class pynessie.model.ReferenceSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow_oneofschema.one_of_schema.OneOfSchema

Schema for Nessie Reference.

dump_fields: typing.Dict[str, ma_fields.Field]
fields: typing.Dict[str, ma_fields.Field]

Dictionary mapping field_names -> Field objects

get_obj_type(obj)[source]

Returns the object type based on its class.

Return type

str

load_fields: typing.Dict[str, ma_fields.Field]
opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
type_schemas = {'BRANCH': <class 'marshmallow.schema.Branch'>, 'TAG': <class 'marshmallow.schema.Tag'>}
class pynessie.model.SqlView(id, dialect, sql_text)[source]

Bases: pynessie.model.Contents

Dataclass for Nessie SQL View.

dialect: str
id: str
pretty_print()[source]

Print out for cli.

Return type

str

sql_text: str
class pynessie.model.Tag(name, hash_=None)[source]

Bases: pynessie.model.Reference

Dataclass for Nessie Tag.

hash_: Optional[str]
name: str
class pynessie.model.Transplant(from_ref_name, hashes_to_transplant)[source]

Bases: object

Dataclass for Transplant operation.

from_ref_name: str
hashes_to_transplant: List[str]
class pynessie.model.Unchanged(key)[source]

Bases: pynessie.model.Operation

Unchanged single key.

key: pynessie.model.ContentsKey

pynessie.nessie_client module

Main module.

class pynessie.nessie_client.NessieClient(config)[source]

Bases: object

Base Nessie Client.

assign_branch(branch, to_ref, to_ref_hash=None, old_hash=None)[source]

Assign a hash to a branch.

Return type

None

assign_tag(tag, to_ref, to_ref_hash=None, old_hash=None)[source]

Assign a hash to a tag.

Return type

None

cherry_pick(branch, from_ref, old_hash=None, *hashes)[source]

Cherry pick a list of hashes to a branch.

Return type

None

commit(branch, old_hash, reason=None, author=None, *ops)[source]

Modify a set of Nessie tables.

Return type

Branch

create_branch(branch, ref=None, hash_on_ref=None)[source]

Create a branch.

Parameters
  • branch (str) – name of new branch to create

  • ref (Optional[str]) – branch or tag to fork from (‘hash_on_ref’ should be reachable from this reference)

  • hash_on_ref (Optional[str]) – hash to assign ‘branch’ to

Return type

Branch

Returns

Nessie branch object

create_tag(tag, ref, hash_on_ref=None)[source]

Create a tag.

Parameters
  • tag (str) – name of new tag to create

  • ref (str) – name of the reference via which ‘hash_on_ref’ is reachable

  • hash_on_ref (Optional[str]) – hash to assign ‘branch’ to

Return type

Tag

Returns

Nessie tag object

delete_branch(branch, hash_)[source]

Delete a branch.

Parameters
  • branch (str) – name of branch to delete

  • hash – hash of the branch

Return type

None

delete_tag(tag, hash_)[source]

Delete a tag.

Parameters
  • tag (str) – name of tag to delete

  • hash – hash of the branch

Return type

None

get_default_branch()[source]

Fetch default branch either from config if specified or from the server.

Return type

str

get_log(start_ref, hash_on_ref=None, max_records=None, **filtering_args)[source]

Fetch all logs starting at start_ref.

start_ref can be any ref.

Note

this will load the log into local memory and filter at the client. Currently there are no primitives in the REST api to limit logs or perform paging. TODO

Return type

Generator[CommitMeta, Any, None]

get_reference(name)[source]

Fetch a ref.

Parameters

name (Optional[str]) – name of ref to fetch

Return type

Reference

Returns

Nessie reference

get_values(ref, *tables, hash_on_ref=None)[source]

Fetch a table from a known ref.

Parameters
  • ref (str) – name of ref

  • hash_on_ref (Optional[str]) – hash on reference

  • tables (str) – tables to fetch

Return type

Generator[Contents, Any, None]

Returns

Nessie Table

list_keys(ref, hash_on_ref=None, max_result_hint=None, page_token=None, query_expression=None)[source]

Fetch a list of all tables from a known branch.

Parameters
  • ref (str) – name of branch

  • hash_on_ref (Optional[str]) – hash on reference

  • entity_types – list of types to filter keys on

  • query_expression (Optional[str]) – A CEL expression that allows advanced filtering capabilities

Return type

Entries

Returns

list of Nessie table names

list_references()[source]

Fetch all known references.

Return type

List[Reference]

Returns

list of Nessie References

merge(from_branch, onto_branch, from_hash=None, old_hash=None)[source]

Merge a branch into another branch.

Return type

None

Module contents

Top-level package for Python API and CLI for Nessie.

pynessie.get_config(config_dir=None, args=None)[source]

Retrieve a confuse Configuration object.

Return type

Configuration

pynessie.init(config_dir=None, config_dict=None)[source]

Create a new Nessie client object.

Parameters
  • config_dir (Optional[str]) – optional directory to look for config in

  • config_dict (Optional[dict]) – dictionary of extra config arguments

Return type

NessieClient

Returns

either a simple or rich client

Example

>>> client = init('/my/config/dir')