Cerberus 1.0 has been released

After a one year long development cycle I am proud to announce that version 1.0 of Cerberus, the data validation and transformation tool for Python, is finally out. A while ago I wrote an article on the new features and breaking changes that come with it, so please check it out carefully along with the changelog.

I just wish to reiterate my gratitude towards all the contributors to the project. The ones who specifically worked on this awesome release, those who made it all possible, are: Matthew Ellison, Dominik Kellner, David Kirkendall, Damián Nohales, calve, Jonathan Huot, Roman Redkovich and of course the one and the only Frank Sachsenheim, whose role was pivotal to this release.

If you want to get in touch, I am @nicolaiarocci on Twitter.

Eve SDK for .NET v0.2 is out in the wild

I just released a long overdue update to Eve.NET. This release marks a significant improvement over the previous one, which was more a prototype than a real package. New features are as follows:

  • PostAsync() supports bulk inserts
  • DeleteAsync() supports bulk deletes
  • GetAsync() has a softDelete option to include soft-deleted documents with query results
  • GetAsync() has a rawQuery option to pass raw Eve queries to the server
  • BearerAuthenticator class adds support for Bearer Token authentication

Several fixes made it into this release and, most importantly, I switched to portable Profile259 which offers support for the following platforms: Xamarin.iOS, Xamarin.Android, WinPhone 8.1, Windows 8, .NET 4.5+. Yes, that means no more support for .NET 4.0. See the changelog for details.

Eve.NET v0.2 is on NuGet so you can install it either from Visual Studio or with the Package Manager console. Enjoy!

If you want to get in touch, I am @nicolaiarocci on Twitter.

Introducing SimpleObjectCache a simple cross-platform object cache for .NET systems

SimpleObjectCache is a very simple permanent, cross-platform, asynchronous key-value object cache for .NET. It comes with built-in SQLite 3 support. Alternative backends can be added by implementing the IObjectCache or IBulkObjectCache interfaces.

How it works

First, you need to set the ApplicatioName. This is also going to be the folder where your cache will reside. Depending on the host OS the location of this folder might be different. On Windows it would be something like C:\ProgramData\<ApplicationName>\SimpleObjectCache.

Let’s instantiate SimpleObjectCache so we can use it:

Now we create a Person, then store it into our cache.

As we insert an object into the cache we can also set its expiration date:

Inserting an object with an already existing key, which we just did, will overwrite the previous object with the same key. Retrieving the object is a matter of providing its key:

To remove the object from the cache we use the Invalidate method:

Bulk inserts are also possible:

Note that we just set the Tom and Mike expiration date to yesterday. Now let’s add John again. For him however, we set an expiration date which is bigger than Tom’s and Mike’s:

The Vacuum method removes expired objects from the cache. So Tom and Mike, whose dates are passed, are going to be purged by the following command:

Now let’s get all the available Person objects from the cache.

Since Tom and Mike are gone, we only got one object back, and that’s our very own little John.

Installation

SimpleObjectCache is on NuGet. Run the following command on the Package Manager Console:

Or install via the NuGet Package Manager in Visual Studio.

Wrapping it up

We needed a simple cache that we could use as a component of our cross-platform storage system (more on that in a future post). We wanted the cache to also run seamlessly on the old .NET 4.0 framework. Unfortunately Akavache, to which this project is blatantly inspired, does not run on .NET4, so I decided to roll out my own simplified alternative. This project also offered a great occasion get my feet wet with bait-and-switch portable classes and a few other interesting challenges.

Currently supported platforms are iOS and Android (Xamarin) and .NET Framework versions 4.0 and .NET 4.5+.

If you want to get in touch, I am @nicolaiarocci on Twitter.

EveGenie makes Eve schema generation a breeze

Released by the nice folks at Drud, EveGenie is a tool for making Eve schema generation easier.

Eve’s schema definitions are full of features, but can take a good amount of time to create when dealing with lots of complex resources. From our experience, it’s often helpful to describe an endpoint in JSON before creating it as an Eve schema. This allows you to make quick decisions about the structure of your entities without spending time moving schema code around. This is where EveGenie comes in.

EveGenie saves time by creating a ready to use Python Eve schema from a very simple JSON representation of a set of resources.

Interested? Good! Matt Tucker (@ultimateboy) has a getting started with EveGenie article up for you, so make sure to check it out.

Meet Eve-Swagger the swagger.io extension for your Eve powered REST API

Eve-Swagger is a swagger.io extension for Eve powered RESTful APIs. It has been around for a while on GitHub but I never managed to officially release it. So rejoice! it is now available on PyPI.

But what is Swagger, and why is it useful to your RESTful API? With a Swagger-enabled API you can get interactive documentation, client SDK generation and discoverability, all for free. From Swagger website:

Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.

When Eve-Swagger is installed and properly configured your Eve API exposes a special /api-docs endpoint which returns a 100% swagger-compliant JSON response. This JSON can then be processed by the swagger tools like Swagger UI and Swagger Editor. Here we can appreciate Swagger UI providing API documentation out of the box (click to zoom):

Swagger UI

And this me playing around the API specification with Swagger Editor (click to zoom):

Swagger Editor

Like most Eve extensions Eve-Swagger comes as a standard Flask Blueprint and, as such, using it is very simple:

Once the blueprint has been registered all you have to do is add a SWAGGER_INFO node to your settings. It maps to a swagger infoObject and contains some simple, human readable information. The extension will also scan your endpoint settings to figure out the API graph and document it. Of course, in order to not to clutter your launch script, you could (and probably should) set SWAGGER_INFO in your configuration file.

Installation is super easy:

This is just version 0.0.2 so many parts might still be moving, but you are encouraged to start using it right away. Also if you appreciate this extension please let me know by either starring it on GitHub or with a tweet or email, so I will know that I should really try hard and allocate more time to this project. As always, feel free to contribute via pull request!

If you want to get in touch, I am @nicolaiarocci on Twitter.

Cerberus 1.0 is coming and it is going to be awesome

Cerberus is a lightweight and extensible data validation library for Python. Beta has been around since 2012. During this time Cerberus has been serving as the validation system for Eve core. It has been also adopted by a quite a lot open source projects, averaging around 18K downloads per month on PyPI and collecting some remarkable endorsements.

All things considered, I would dare to claim that Cerberus is battle tested to death. This is, in fact, one reason why I believe that the time for a canonical and stable release has come. Another reason is that next release is a major one. It brings a ton of important new features along with very significant code refactoring and a redesigned, powerful API. Third, next release breaks backward compatibility, and we want to signal that in the version number.

So next Cerberus release will be 1.0. If you have been following the development this will come as no surprise, as a Release Candidate has been out for a while. As a Cerberus user you will want to take the plunge and upgrade to 1.0 because well, it is just too cool to be true. If new to Cerberus you will also want to adopt 1.0 right away, for the same reason. If you are new however, make sure you get the basics covered before reading further. By the way, at latest PyCon Italy I gave a talk on Cerberus which also included a preview of several 1.0 features. You can check the slides to get a general idea of the tool, its usage, and upcoming features.

Let’s now look at some of the relevant features and changes introduced with Cerberus 1.0. For a (mostly) accurate list of changes and new features, have a look at the changelog.

Continue reading

Fattura Elettronica per la PA v0.2.1

Ho appena pubblicato su NuGet l’ultimo aggiornamento di FatturaElettronicaPA, il package .NET per la compilazione e convalida delle fatture elettroniche per la Pubblica Amministrazione. Si tratta della versione 0.2.1 che fa proprie le novità annunciate il 9 Maggio scorso:

A partire dal 9 maggio 2016 sono introdotti nuovi controlli sui file trasmessi al Sistema di Interscambio. Per consentire il necessario adeguamento al nuovo regime di verifiche, fino al 31 luglio 2016 il mancato superamento di uno o più di questi nuovi controlli non comporterà lo scarto del file ma solo una segnalazione che verrà riportata all’interno della Ricevuta di consegna o della Notifica di mancata consegna. Dal 1 agosto 2016 i file che non dovessero superare uno o più di questi controlli verranno scartati.

Se per ora i nuovi controlli non sono vincolanti, lo saranno a partire dal 1 agosto. Poiché si tratta di una serie di convalide sui conteggi consiglio di passare alla versione 0.2.1 al più presto, così da verificare che in effetti le vostre fatture elettroniche siano in linea con le aspettative della PA: potreste avere qualche sorpresa.

Nel nostro caso, per esempio, abbiamo dovuto prendere atto che gli importi imponibili relativi alle aliquote IVA, così come le corrispondenti imposte, devono essere indicati al lordo degli eventuali sconti generali del documento, pena il rifiuto dello stesso da parte del sistema di interscambio. Date una occhiata al changelog per l’elenco completo delle novità.

Voglio aggiungere un commento sulle modalità di pubblicazione degli aggiornamenti tecnici da parte di Agenzia Entrate/Sogei. Sebbene siano dotati di data e numero di versione, questi sono da considerarsi, ad essere buoni, puramente indicativi. Per esempio l’attuale versione 1.2 dell’elenco controlli è stata aggiornata “silenziosamente” un paio di giorni dopo la pubblicazione (hanno aggiunto una tolleranza di 1 Euro al controllo 00422). Così lo sviluppatore incauto che si limiti a controllare la data e il numero di versione del documento rischia di vedersi respingere fatture per lui del tutto corrette, a meno che non di prenda la briga di verificare, riga per riga, la corrispondenza tra la documentazione in suo possesso e quella disponibile sul sito in quel momento. Chiaramente in PA non hanno idea di cosa sia il Semantic Versioning.

Un ringraziamento al mio collega Stefano Gardini. Il suo nome non compare nelle commit ma, quando si stratta di fatturazione e contabilità, è come se ci fosse.

If you want to get in touch, I am @nicolaiarocci on Twitter.

My Crazy Speaking Month

April was definitely my crazy Speaking Month. After an almost one year long self-imposed conference hiatus, I was challenged to deliver four different talks, attend two discussion panels, give one live demo and release one interview. All in a three weeks period span. First I went to PyCon Sette in Florence. A few days later a plane took me to St. Petersburg, Russia, for PiterPy. Finally, the next weekend I was in Rome for the Western Europe Microsoft MVP Community Day. In the meantime several Channel 9 TecHeroes episodes were due for release. This was of course super exciting. And challenging.

This post is not much (or only) about my talks or performance, but hopefully more around the different communities I got a chance to interact with.

PyCon Sette, Florence

PyCon Italy is like home to me. Here, back in 2012, I gave my first Python talk which also happened to be my first English talk ever. Back then Italy was hosting EuroPython 2012, the general assembly of the European Python community, so we had people flying in from all over the continent (and beyond). And I was there all alone, a .NET guy who knew no one, pretending to teach pythonistas how to properly build a REST API powered by MongoDB and Flask. Talk about putting myself out of my comfort zone. That talk was important for many reasons, I won’t go into them, suffice to say that, without it, the Eve project would not exist now.

The following years I went back with more talks. After the three booming EuroPython years we saw the number of PyCon attendees drop from the 700s to the about 150 at PyCon Cinque. Following that first post-EuroPython event however the numbers started to raise. Fast. So fast, in fact, that this year we ended up celebrating the all-time high of 575 attendees. An impressive result, as it almost tops EuroPython numbers. We owe a lot to the skill, expertise and braveness of the PyCon Italy organizers. They are simply awesome, and tireless. Such a result, however, also a is a testimony of how strong, vibrant and resilient the Italian community around Python is.

This year I was there to give my first Cerberus talk. The room was packed full, everything went smoothly (at least from my perspective) and when all was done and said I was left with the impression that the project was well received. My only regret is that I totally forgot to submit the talk for the English track. I also took part in the Python Web Framework Royal Rumble, a panel in which Django, Flask, Pyramid and TurboGear champions were to fight each other. I was defending the Flask flag, and it was a lot of fun.

The Italian Python community is cozy and friendly as always, stronger than ever. PyCon in Florence keeps improving its already high standard. My only suggestion would be to reverse the English/Italian tracks ratio. I would go for an all-English conference with just one track for Italian language. I am sure a lot of guests would flock in from nearby countries. I mean who would not want to visit Florence, and Tuscany Plus, many pythonistas already have very fond memories from the Italian EuroPython years and I am sure they would love to come back.

PiterPy, St. Petersburg

PiterPy is an important and very well organized Python event which gathers attendees not only from St. Petersburg, but also from other Russian cities and nearby countries.

I was invited by the conference organizers to talk about project Eve. I was honoured, excited and curious to meet fellow pythonistas from the Eastern Europe. Other headliners were Chris Ewing, Gael Varoquaux, Hynek Schlawack, Simone Soldateschi and Fabio Natali. As you can tell, we all have different backgrounds and specialize on different things, as it should be when you want to present your audience with different interesting aspects of your stack of choice.

I did my Eve talk and then even managed to sneak in lightening talk on Cerberus. I was also interviewed by Vladimir Filonov (I think the recording is due out soon) and to my surprise the interview was not on my open source activity but rather on the Italian Python community. It turns out that in Russia they care a lot about the community, and they are eager to know more about other Python communities scattered all around Europe. Freaking awesome, if you ask me.

Organizers were professional and friendly all the time, letting me feel comfortable right from the start. In fact I was just off the plane when I met with Maxim Klymyshyn, who took me from the Airport to the conference location. The venue itself (Original Sokos Olympia Garden, conveniently located close to St. Petersburg’s city center) was probably one of the best, if not the best, conference venue I ever been at. And what about the attendees? They were very welcoming with their international guests and language barrier was not an issue as many of them speak very good English (often better than mine). Be warned however, when given the opportunity they will not hesitate to challenge the unwary speaker with the hardest of questions. I am told (by the attendees themselves) that this is in fact a trait of the Russian people. They won’t be shy when they have something to say. As a speaker, I really appreciated the attitude!

The day after the conference a cultural trip to Catherine Palace in Pushkin was planned for both speakers and attendees. That was terrific. Should you go to St. Petersburg, on a business trip or just as a tourist, make sure you visit Catherine Palace. You won’t regret it.

My eternal gratitude goes to Vladimir Shulyak and Dmitry Nazarov for taking me and my new buddy Chris Ewing out for diner and then on a super nice walk around the city center. Special thanks to Serge Matveenko, Diana Lyubavskaya and the rest of the team for inviting us and, most importantly, for putting up such a great event. I am sure PiterPy will soon become a relevant event within the international community.

Western Europe MVP Community Day, Rome

This was my first time as a MVP to a Microsoft event. Not only that. This was actually a MVP-only event and I was there to give a talk to experienced MVPs who, for the most part, have been in the program for years. Kind of intimidating, although I was reassured by the fact that my proposal had been voted by the MVP community itself.

Like at my first Python conference years ago I knew no one there, not personally at least, so it took some balls win my shyness and introduce myself to the first person I recognized, that one being Alessandro Del Sole, a long time MVP veteran. He and his pals were super nice and only moments after introducing myself to them I was already feeling part of the community. A very empowering feeling. Later during the evening and even more so the following day, at the conference, I got to meet and know a lot of new friends, all very knowledgeable in their craft, which is awesome.

I would say that the focus of the event was about Microsoft’s new openness toward other stacks and communities, which also helped in making me feel comfortable. I gave my Real Life .NET Cross Platform talk, with good feedback. SimpleCache, which was used as an example project and wasn’t really the main topic, got a lot of interest so I may actually release it on NuGet soon (blog post coming). My highlight for the event though, would be Karen Juhl keynote during which I suddenly realized that a picture of me, along with quotes from one of my articles, was being shown on stage. It took me a few seconds to realize what was going on, as it was totally unexpected. That was crazy, and mesmerizing. Later, when I got to talk with Karen, I learned that that very same slide has been used at several MVP events across Europe. So exciting!

The conference was closed by an Open Source Communities Panel, to which I was invited as a member of multiple communities.

The next day I was at the OpenDomus.net event, where I got a chance to repeat my cross platform talk (this time in Italian), and then to give a live demo of Ubuntu Bash on Windows. That one was interesting, and surprising I think, for many attendees. A few days later, with Lorenzo Barbieri, we recorded a Best of Build 2016 episode on the same topic (link below).

TecHeroes Interlude

April and March were also the months in which I and Lorenzo Barbieri recorded and released a few MSDN TecHeroes Italy episodes:

Wrapping it up

As I mentioned at the OSS panel I am lucky to have an active role in more than one community and to work every day with diverse technologies. Now, most of the times the problems tackled by these stacks are, in fact, the same. Besides the obvious differences in semantics, what really changes and is most interesting to me is the approach, the path if you will, taken by each individual stack. For me, being exposed to multiple approaches and therefore getting a chance to appreciate the differences, the pros and cons of each one (which tend to vary depending on the situation at hand) has been invaluable. I could (and probably should) fill a blog post with the things I learned working on Python that I am now using, with profit, in C#. And vice-versa.

And what about the communities? Different communities, again, expose me to different cultures. That is a good thing. Being rooted into a community is great but being active in multiple communities is even better, in essence for the same reasons you’d want to become a polyglot programmer.

So my invite is to get involved once again, no matter how active and fit you are into a stack and its community. Try something totally new, even if it doesn’t really sound like something immediately useful to you. Because you know, cross-pollination is a good thing. And you get to party twice the time, too.

If you want to get in touch, I am @nicolaiarocci on Twitter.

Eve REST API Framework v0.6.2 is out

Today I released Eve 0.6.2. It includes many fixes and improvements over the previous releases. Areas addressed are CORS management, soft deletes, token authentication, oplog, data validation, and others. Please see the changelog for details.

Work on v0.7 is also ongoing. It will include new features such as support for the MongoDB Aggregation Framework (docs) and a few breaking changes, so you might want to check it out in advance.

Special thanks to Arnau Orriols, Cyril Bonnard, Hamdy, Luca Di Gaspero, Manquer, Nick Park, Patrick Decat, Prayag Verma, Ralph Smith, Stratos Gerakakis, Valerie Coffman and Wei Guan who contributed to this release.