Using Sparts to Write Python Code

Sparts is a Python library developed by Facebook to eliminate skeleton code. The main purpose of the library is to make it easy to implement services without having to write excess code, so you can create prototypes really quickly. To learn the basics of Sparts, be sure to read the documentation.

The way that Sparts works is that it splits up any service into two parts, the core “service” and the “tasks”. Tasks typically refers to background/offline processing, while service includes any shared functionality. So to create any new custom logic, you just need to subclass VService (sparts.vtask.VService) and run its initFromCLI() and you’re good to go. Tasks (sparts.vtask.VTask), on the other hand, are used to trigger your programs to take action. Without them, the service class would be pretty useless.

Together, the services and tasks at the core of Sparts come together to make your life a little easier and require a lot less code writing when it comes time to implement new services into your products or create new prototypes. Check it out for yourself here.

Leave a Reply

Your email address will not be published. Required fields are marked *