Events, LABS

EUROPYTHON 2018 Asyncio learnings

October 23, 2018

October 23, 2018 by hectoralvarez

EDINBURGH
Thanks to Ebury’s learning program, Héctor Álvarez and Jesús Gutiérrez were selected to attend EuroPython in Edinburgh.

EuroPython is a yearly conference in Europe that focuses on Python programming language and its ecosystem . This year’s sessions were held at the Edinburgh International Conference Center; an amazing building in the core of the city, just a stone’s throw away from the historical city of Edinburgh.

More than 1200 programmers and python lovers from 51 countries attended the event. With over 150 sessions in 7 tracks we were prepared to take away as much new information as possible.

From the outset, it was clear that the hottest topic in EuroPython was asynchronous programming. First integrated into 3.6 Python, and in various iterations since, it is still entirely possible to use Python without needing or even knowing about the asynchronous paradigm. However, if you are interested in the nuts and bolts of the tech involved, read on.

For the beginners out there, your central processing unit (CPU) follows a synchronous programming model, which means that things happen one by one. For example, when you create a function that performs a long-running action, it returns only when the action is finalised and it can return the result. Even when different programs that are run by your Operating System (OS), which is programmed synchronously, the OS manages them asynchronously. This is why multitask Operating Systems have been used for a long time.

The pitfall of asynchronous programming is that it’s difficult to know which of the coroutines has the execution time, and which coroutine spawned which; the event loop obviously knows but the programmer doesn’t.

The recently launched Python3.7 tries to solve that problem with inheritance of tags.

Under the asynchronous topic:

Asyncio in python 3.7 and 3.8 (Yury Selivanov)

Asyncio in production (Hrafn Eiriksson)

Asyncio in practice: We did it wrong (Lynn Root)

Here, I’ll briefly explain how the asynchronous programming works since Python 3.5.

As mentioned before, classic program code is executed in a single event line.In asynchronous programming, however, code is executed in a single loop. That loop is part of the code that orchestrates what’s executed when, inside the loop, there are a group of tasks—coroutines. Coroutines are defined with the reserved word async.

When a coroutine has been executed, it reports to the loop when it’s waiting for an external resource using the reserved word await.

When the loop detects that a coroutine is awaiting, it gives the execution time to the next coroutine, the loop then stores the memory state and where it’s waiting. When the external resource finally gives the response it fires a callback so knows that the coroutine is ready to keep working.

That’s  the theory, but now it’s time to look at the code:

 

import asyncio
import logging


logging.basicConfig(format='%(asctime)s %(message)s', datefmt='[%H:%M:%S]')
log = logging.getLogger()
log.setLevel(logging.INFO)


# define a coroutine
async def sleeper(name, delay):
    """This coroutine will wait for 2 seconds and then keep working."""
    log.info(f"{name}: START (wait for {delay}s)")
    await asyncio.sleep(delay)
    log.info(f"{name}: END (wait for {delay}s)")
    return name

if __name__ == '__main__':
    # create the loop
    loop = asyncio.get_event_loop()

    coroutine1 = sleeper('first coroutine', 2)
    coroutine2 = sleeper('second coroutine', 5)
    task1 = loop.create_task(coroutine1)
    task2 = loop.create_task(coroutine2)

    log.info("main: START run_until_complete")
    loop.run_until_complete(asyncio.wait([task1, task2]))
    log.info("main: END   run_until_complete")


Here at  Ebury, we don’t currently use asynchronous programming because Django (our framework) is not asynchronous. However, there are parts of the code that are slow (like sending an email that will delay for a second), and so in those cases we use a workaround—task executor named celery. If you want to know more about celery, follow this link: https://labs.ebury.rocks/?s=celery

Miscellaneous

Domain Driven Design, Robert SmallShire

Domain Driven Design is an approach to software development that emphasises high-fidelity modelling of the problem domain, which uses a software implementation of the domain model as a foundation for system design.

PEP 557 (data classes) versus the world (Guillaume Gelin)

Data classes are a very controversial feature, yet here it’s explained why they’re useful for us.

Getting started with mypy and type checking (Jukka Lehtosalo)

Mypy , is defined as: a static type checker for Python that aims to combine the benefits of dynamic (or “duck”) typing and static typing.

Static typing can help you find bugs faster with less testing and debugging. In large and complex projects, this can be a major time-saver.

Python decorators: Gift or poison? (Anastasiia Tymoshchuk)

A taxonomy of decorators: A-E (Andy Fundinger)

Python 2 is dead! Drag your old code into the modern age (Becky Smit)

What’s new in Python 3.7 (Stephane Wirtel)

Pythonic code vs. Performance (Łukasz Kąkol)

 

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Javier Vázquez
Salesforce Developer

Events

Ebury Salesforce at the DreamOlé 2018 Event

August 30, 2018

August 30, 2018 by Javier Vázquez

On the 27th of April this year, the Ebury Salesforce team attended DreamOlé; the biggest Salesforce event in Spain, with collaborators and speakers from around the world gathering to share their knowledge, skills and experience with the audience.

The important presentations from our perspective were…

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Development, Events

Takeaways from the 2018 ExpoQA in Madrid

July 23, 2018

July 23, 2018 by Daniel Gordillo

For the fourth consecutive year, Ebury attended the ExpoQA conference during 4-6 June in Madrid. Events such as these are paramount in order to stay updated with the latest news in technology, tools, methodologies and all the nerdy stuff we love.

We would like to highlight the following  presentations:

  • Focus on product quality instead of testing by Dana Aonofriesei. She offered a look into how we need to pay attention to quality in production monitoring. We loved her alert system where the alerts have the status “Pending”, “Researching” and “Solved” to help manage the alerts and give better visibility. In addition, we really liked how her system automatically assigns bugs by “keywords”.
  • Yes, we can. Integrating test automation in a manual context by Andreas Faes. Based on his experience, he talked about implementing test automation processes in his company, up to the point of how developers are using code created by QA (dev in test) to test his developer code, similar to TDD but with tests driven by QA. This is something that we will be looking to apply in our own teams.

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Development, Events

DjangoCon Europe 2018

June 26, 2018

June 26, 2018 by Miguel Ángel Moreno

DjangoCon Europe 2018, the European conference for the Django framework, was held this year in Heidelberg, Germany, from May 23rd – 27th. Professionals from around the world gathered together to enjoy a collaborative environment with talks given on a variety of topics, from philosophical issues, to technical details.

Ebury adopted Django a few years ago now as part of its core technology stack and this conference is always great to look at future opportunities.

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Miguel Torres
Lead Front-end Developer

Design/UX, Development

Introducing huha.js: Analysing User Experience with Javascript

June 22, 2018

June 22, 2018 by Miguel Torres

We love building great products, but a product would be completely useless if it is not properly designed for the people who are meant to use it. This lack of efficiency impacts the user experience (UX) of the solution. But, how can we achieve a good UX when developing a product? Is there a way that we can measure user performance objectively?

By trying to answer these questions, we realised there aren’t any cheap and easy-to-use tools ready for any member of our team. So, since we have some experience in things like building software, we decided to develop our own tool.

We are glad to introduce huha.js, a Javascript framework that is intended to measure the usability and user experience in an automated way, considering the limitations of the model and best practices.

In this post, we would like to share how it was built, in order to get fast and detailed feedback on user experience and be able to provide support to a highly iterative agile development practice.

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Development

Queue tasks in Celery after database commit – Introducing django-transaction-hooks

April 18, 2018

April 18, 2018 by antoniopaez

At Ebury, we use Django and have followed an ongoing upgrade path from 1.3 to 1.5 to 1.7. During that time we have had an issue that was messing with us. You might be familiar with it.

We use celery for  executing asynchronous tasks and Django is our framework with PostgreSQL database.

The issue occurs when an asynchronous task makes use of an object that has been just updated, or  created. There is a dependency with the database, the object might not have the updated status when the asynchronous task starts, or not even exists yet.

We are now able to utilise the  library django-transaction-hooks, which works with Django 1.6 through 1.8, and has been merged into Django 1.9+.

What is important with this library is that adds the event “on_commit” to manage timing with database transactions. So, we  can use this for scheduling when to queue tasks for celery workers. The main advantage comes when we want to queue using an object created into an atomic transaction. Consider the following example:

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Events

PyConEs 2017 overall

October 31, 2017

October 31, 2017 by Jesús Gutiérrez

In September 2017 Ebury went to PyCon Spain 2017 which took place in Cáceres (Extremadura), at the beautiful location of San Francisco’s Cultural Complex.

Read on for insights on refactoring, unicode, serverless, testing factories, diversity in the work place and open source!

In this article we would like to give pull out some key talks at the conference and the different roles that we had there:

  1. As sponsors: We love Python so we are PyConEs sponsors as part of our commitment. Its great to meet others passionate about getting the best out of python and of course, because we are hiring.
  2. As participants: We want to learn, listen to interesting speakers and share ideas and experiences (we are not a Developersaurus Rex Company).

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Javier Vázquez
Salesforce Developer
Miguel Torres
Lead Front-end Developer

Development

Security in JavaScript: An AmsterdamJS story

July 18, 2017

July 18, 2017 by Miguel Torres

Given that security is so important for our applications, then as front-end developers, why are we we so intimidated when we have to secure our projects? How can we easily improve the security layer in our own JavaScript code?

I recently attended the 2017 AmsterdamJS Conference 2017, where I met Ingrid Epure. I would like to share some useful tips from her workshop, The Art of Keeping Your Application Safe.

Read more

Share on Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn