Datatamer / tamr-client

Programmatically interact with Tamr
https://tamr-client.readthedocs.io
Apache License 2.0
11 stars 25 forks source link

Proposal for extensibility #84

Closed DerrickRice closed 4 years ago

DerrickRice commented 5 years ago

💬 RFC

A proposal for cases where an end user wants to use this library, but add additional functionality without the difficulty of monkey-patching or of permanently modifying the library (even within a single Python runtime).

My proposal is to add a (barely-documented) class mapping argument to the Client which is used whenever a library class is invoked (i.e. a method is called on it, including it's constructor).

See https://github.com/DerrickRice/unify-client-python/commit/a6b644c8efcbdc2cf6344603fdff732433e530d4

💻 Examples

def example():
    class_mapping = {ProjectCollection: MyProjectCollection}

    client = Client(
        UsernamePasswordAuth("username", "password"), class_mapping=class_mapping
    )

    assert isinstance(client.projects, MyProjectCollection)
pcattori commented 4 years ago

@yizhiyintamr , @alex-batchelor and I discussed this offline.

Extensions will be privately hosted in Datatamer/tamr-client-extensions.