Posts

DynamoDB in pytest-dbfixtures

pytest-dbfixtures If you use pytest maybe you have heard about pytest-dbfixtures : Pytest dbfixtures is a pytest plugin that makes it a lot easier to set up proper database or storage engine for testing. Simply use one of provided fixtures that start predefined clean database server for your tests or creates server more tailored for your application by using one of provided factories. This plugin is very useful if you have integration tests in your project, and you want to perform tests on a database for example. You will find information how to use it in the documentation . Currently, the plugin supports: Postgresql MySQL Redis Mongo Elasticsearch RabbitMQ And recently, we have added support for DynamoDB . Here , you will find how to run DynamoDB on your computer. And, here we are. If you want to use it in production, you want to test it locally. dynamodb fixture If you still do not use pytest, go to the pytest page and read how to use it, now. If you want to

PyCharm - tips, tricks and plugins

Image
Introduction I have been using Vim for a long time, but recently I have started using PyCharm too. This tool has many proper features and plugins. I will show you some of them. You will find here many gifs instead of text. In this way, you can easily see how it works, how it looks, etc. Plugins   .ignore This plugin was written by my friend. Here is more info about it. It will generate new ignore files for you. BashSupport Supports syntax highlighting, rename refactoring, documentation lookup, inspections, quickfixes, etc. Dash A smart and simple plugin that provides keyboard shortcut access for Dash . KeyPromoter Shows you how easy you can make the same action using only a keyboard. Lua Support for LUA. Markdown Support for markdown. YAML/Ansible support I don't want to write again "Support for YAML/Ansible". Tips & Tricks You do not know what to do? Do not be scared! Just use TODO. You have access to Termin

AWS Lambda and Python

Image
What is the AWS Lambda? AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume - there is no charge when your code is not running. So, you can build a scalable application without managing servers. Something like a microservice without servers. Serverless! Hence, your function must be written in a stateless style. If you want to store something somewhere, you can connect to S3, Redshift, DynamoDB, etc. AWS Lambda will start to execute your code within milliseconds. I am not going to write a tutorial step by step. You will find here only a handful necessary information. Limits Let's look at the limits (all limits are default, you can ask guys from AWS to increase them). You have access to an ephemeral disk with limit 512 MB (access to /tmp only). Your function must be finished within 300 seconds (it is a default max value; if you want you can set 10 seconds also); if not AWS Lambda will terminate it. Zip

How you can use watchdog to improve your productivity.

Watchdog is a python API and shell utilities to monitor file system events . I am using it for tasks like build sphinx docs or run tests after changes in file/directory. It's very easy to use. For instance, you are writing documentation and after each saving file you have to run command like "make html". So, why you don't this automatically?   Simple command: watchmedo shell-command --command="make html" --wait source What does it? Watchdog began to watch source directory. If something in this directory will be changed, then watchdog will run your command (make html). Simply, right? If you use Firefox you can install Auto Reload add-on. Auto Reload automatically reloads matching tabs when selected local files change. So, after saving file, your documentation will build automatically and Firefox automatically will refresh tab with documentation in browser, brilliant! You can also use patterns. For example, you want to run tests after saving file

Hello everyone!

From today I am going to write blog in English and also I will write more posts.

Rzadko wykorzystywane typy danych

Wstęp Przy codziennej pracy z pythonem często korzystasz z takich typów danych jak słownik, lista, krotka czy zbiór. Ale warto pamiętać, że istnieją również inne typy danych, które często mogą Ci się przydać, a o których niekoniecznie słyszałeś. Przedstawię kilka z nich, które moim zdaniem są warte uwagi. Counter Typ ten przydaje się wtedy gdy chcesz np. sprawdzić ile razy występuje dany obiekt w zbiorze i dodatkowo chcesz to trzymać jako słownik. Przykład: deque Obiekt deque idealnie nadaje się do stosu lub kolejki . Dodawanie oraz pobieranie elementu jest zbliżone do O(1); nie ważne czy pobierasz z końca czy z początku. Jeżeli jednak chcesz dostać się do elementów po indeksach lepiej jest skorzystać z listy, która jest do tego przystosowana, więc siłą rzeczy jest szybsza. Poniżej, krótkie porównanie: defaultdict defaultdict przydaje się tam, gdzie chcesz stworzyć słownik w którym przy dostępie ma już mieć zdefiniowaną domyślną wartość. Zamiast martwić się sprawdz

Pylibmc, ultramemcache i python-memcached

Wstęp W ubiegłym roku pisałem o ultrajsonie , który wypadł bardzo dobrze. Przedwczoraj natrafiłem na bibliotekę ultramemcache , którą również postanowiłem przetestować i sprawdzić czy jest ultra. Do porównania wykorzystam biblioteki python-memcached oraz pylibmc . Pierwszy test odbył się standardowo poprzez odpalenie jednego procesu. Drugi natomiast z wykorzystaniem czterech procesów co znacznie przyspieszyło działanie. Jeden proces: python-memcached ultramemcache pylibmc Cztery procesy: python-memcached ultramemcache pylibmc Wyniki Testy wykonałem kilka razy dla każdego ze skryptów i wybrałem najlepsze wyniki dla danej biblioteki. Był to bardzo prosty test, ale da się zauważyć spore różnice w szybkości działania tych bibliotek. W przypadku jednego procesu ultramemcache poradził sobie najlepiej, chociaż pylibmc jest tuż tuż... Jeżeli chodzi o cztery procesy to pylibmc jest zdecydowanym zwycięzcą . Zachęcam do robienia swoich testów. Do sporządzen