Giter VIP home page Giter VIP logo

paprika's Introduction

Hi there, I'm Rayan ๐Ÿ‘‹

๐Ÿ–ฅ๏ธ ML Engineer @ Meta

๐Ÿ”— rayanht.xyz

paprika's People

Contributors

lhl2617 avatar rayanht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paprika's Issues

Tests + Coverage

Issue

We're writing code that leverages highly unusual (maybe even suspicious in some instances) python features with no assurance of correctness.

Mitigation

Unit tests + automated coverage reports (codecov?). We need to test the behaviour of single decorator as well as common combinations.

`pickle` decorator for `class`

Is your feature request related to a problem? Please describe.
Often it is required to serialise some data and then deserialise them for use. An example is during machine learning where it would be convenient to persist train/val/test splits.

Describe the solution you'd like
A @pickle decorator for a data class.

@pickle
@data
class Foo:
    x: int

This should override two methods (naming tentative for now)

def __serialize__(self, file_name: str):
    # Serializes self into a pickled format then save into file_name
    pass
@staticmethod
def __deserialize__(file_name: str):
    # pickle.load the pickle file at `file_name`.
    pass

Describe alternatives you've considered
Doing it manually.

Additional context
Docs: https://docs.python.org/3/library/pickle.html
It would be nice to be able to specify the protocol in the decorator as well, e.g.
@pickle(protocol=5). Other pickle parameters as per docs are desireable.

Performance metrics decorators

Feature Description

We need a family of decorators that allow us to seamlessly benchmark a function with respect to various metrics (number of data accesses, wall time...). Stretch goal: automated hotspot/hot path analysis

Re-structure the package

Issue

All decorators are implemented in __init__.py. This will be bad for maintainability once the file gets bigger.

Mitigation

We should probably split the decorators into different python files (potentially following the structure from the documentation?) and import those inside __init__.py

Fix the behaviour of combining @data and @singleton

Describe the bug

When combining @singleton with @data, @singleton should come before @data. Combining them the other way around will work in most cases but is not thoroughly tested and relies on assumptions that might not hold.

Expected behavior
There should be a single correct way of emulating this behaviour. We should raise an immediately actionable error when they are combined in a way that isn't guaranteed to function.

@getter @setter feature request

It would be great if paprika handled @getter and @Setter decorators. This makes code much easier to maintain. There a really useful tool Lombok, that does this for you in Java. It would be great to see that in Python.

I would be happy to help out with this feature once I have more availability.

Github Actions: Use poetry + Coverage without breaking codecov

The right way to set up a poetry CI env is shown in #14 in .github/workflows/unittest.yml.

The below was tried for .github/workflows/unittest.yml but does not work due to Codecov failures.

name: Test and collect coverage
on: [push, pull_request]
jobs:
  run:
    runs-on: ubuntu-latest
    env:
      OS: ubuntu-latest
      PYTHON: "3.9"
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: Setup Python
        uses: actions/setup-python@master
        with:
          python-version: 3.9
      - name: Setup Poetry
        uses: abatilo/[email protected]
        with:
          poetry-version: 1.1.4
      - name: Install dependencies
        run: poetry install
      - name: Collect coverage
        run: poetry run coverage run -m unittest
      - name: Upload Coverage to Codecov
        uses: codecov/codecov-action@v1
        with:
          verbose: true

The codecov step apparently passes, but the codecov website showed that it failed without much reason.

My guess is that the previous workflow.yml file has a faulty .env in which the env entry gives 3.9 for python, but the Setup Python step uses a 3.7 version instead. This makes the env mismatch problem persist, but that doesn't make sense to be honest.

The difference in running the test poetry run coverage run -m unittest vs. coverage run -m unittest may be an issue as well, but running test -f .coverage for the former does not fail.

Additional decorators

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
A clear and concise description of what you want to happen.

This blog post has few decorators that might be useful to integrate in paprika.

Describe alternatives you've considered
N/A

Additional context
N/A

@to_string: decorated_class.__dict__[attr], "__call__")) KeyError: 'xxx'

When I decorated my class with @to_string decorator, I got a KeyError. I found that there is a problem with the source code after I debugged.

  attributes = [
      attr
      for attr in dir(self)
      if not attr.startswith("_") and not (
          hasattr(self.__dict__[attr], "__call__") if attr in self.__dict__ else hasattr(
              decorated_class.__dict__[attr], "__call__"))
  ]

After I print dir(self) and self.__dict__, the attr of dict(self) are more than self.__dict__, thus result in the self.__dict__[attr] KeyError

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.