๐ฅ๏ธ ML Engineer @ Meta
๐ rayanht.xyz
Paprika is a python library that reduces boilerplate. Heavily inspired by Project Lombok.
License: MIT License
๐ฅ๏ธ ML Engineer @ Meta
๐ rayanht.xyz
We're writing code that leverages highly unusual (maybe even suspicious in some instances) python features with no assurance of correctness.
Unit tests + automated coverage reports (codecov?). We need to test the behaviour of single decorator as well as common combinations.
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.
As title.
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
As title.
Line 139 in 58f2e77
All decorators are implemented in __init__.py
. This will be bad for maintainability once the file gets bigger.
We should probably split the decorators into different python files (potentially following the structure from the documentation?) and import those inside __init__.py
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.
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.
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.