Skip to main content

Pypi Version

About

Whatami is an attempt to abstract configurability and experiment identifiability in a convenient way. It does so by leveraging object introspection and defining a simple, flexible and consistent API that python objects can adhere to, even if they were not originally designed to do it.

It works this way:

  • Objects provide their own ids based on parameters=value dictionaries. They do so by returning an instance of the What class from a method called “what()”.

  • Optionally, this package provides a whatable decorator to provide automatic creation of What objects from objects dictionaries, slots and properties. All attributes will be considered part of the configuration, except for those whose names start or end by ‘_’.

The id strings

They aim to look like they would be generated if __repr__ in python was always implemented taking into account recursion and exposing only result-changing parameters. They pretty much look like python function calls with nested parameters expanded to look like python calls themselves.

Features

  • Represent your computations as standardized ID strings.

  • Pluggable architecture.

  • ID strings can be parsed and manipulated.

  • “whatamise” your library. Included support for:

  • Convenience functions for data tidying.

Example

Whatami is simple but powerful. This example just shows its surface and better docs are coming, but in the meantime, just check the docstrings and unit tests.

# Objects of this class provide a configuration (`What` object)
class DuckedConfigurable(object):
    def __init__(self, quantity, name, company=None, verbose=True):
       self.quantity = quantity
       self.name = name
       self.company = company
       self.verbose = verbose

    def what(self):
        return What('ducked', {'quantity': self.quantity, 'name': self.name, 'company': self.company})

duckedc = DuckedConfigurable(33, 'salty-lollypops', verbose=False)

# The configuration id string sorts by key alphanumeric order, helping id consistency
print duckedc.what().id()
# ducked(company=None,name='salty-lollypops',quantity=33)

# Using the whatable decorator makes objects gain a what() method;
# in this case, what() is infered automatically
@whatable
class Company(object):
    def __init__(self, name, city, verbose=True):
        super(Company, self).__init__()
        self.name = name
        self.city = city
        self._verbose = verbose  # not part of config
        self.social_reason_ = '%s S.A., %s' % (name, city)  # not part of config
cc = Company(name='Chupa Chups', city='Barcelona')
print(cc.what().id())
# Company(city='Barcelona',name='Chupa Chups')

# Ultimately, we can nest whatables...
duckedc = DuckedConfigurable(33, 'salty-lollypops', company=cc, verbose=False)
print duckedc.what().id()
# ducked(company=Company(city='Barcelona',name='Chupa Chups'),name='salty-lollypops',quantity=33)

# We can also decorate functions and partials - use with caution
@whatable
def buy(company, price=2**32, currency='euro'):
    return '%s is now mine for %g %s' % (company.name, price, currency)
print buy.what().id()
# buy(currency='euro',price=4294967296)

Versioning

Since release 4.0.0 whatami uses semantic versioning, where a major version bump happens also if the default id strings can be generated differently, even if no API actually changes.

Metadata

Release files for whatami 5.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whatami 5.1.15
File Size Uploaded Provenance Actions
whatami-5.1.15.tar.gz 67.2 kB Without provenance Details for whatami-5.1.15.tar.gz

Release files / whatami-5.1.15.tar.gz

Download URL whatami-5.1.15.tar.gz
Size 67.2 kB
Tags Source
SHA-256 checksum
How to use checksums
14aa7d226c39f711d9df005cbb84e0bbcdf0c6ef9cc46f29fbe6f6c86d2b2cfc
BLAKE2b-256 checksum
How to use checksums
aa1df9af2ce40d3e8734af5d844e92cdd78617a955628f97b3b9db8a365be4bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for whatami 5.1.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.1.15 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page