In the last article, Fuel Consumption API using database was created. All business requirements are met, now it's time to go on the production! To be on time with current trends, Fuel Consumption Api will run in Docker container.
In the previous article, we've created a Fuel Consumption Api which uses dictionary as a database. The biggest disadvantage of this solution is lack of data persistence. To make our application more useful we'll use SQL database instead of Python dictionary. To achieve this the perfect choice is SQLAlchemy - Python SQL Toolkit and Object Relation Mapper.
REST architecture is currently very widely used. There are many frameworks which allows developer to easily build REST api. Flask is a micro-framework which provides tools that allows to build a web service. Flask-RESTful is an extension to Flask microframework, which simplify creation of REST API.
Reinforcement learning is a type of machine learning that does not require a dataset to learn from. It can learn from the experience it gathers. Let’s think of the network as of an agent in a defined environment. The agent learns about the environment through the actions it performs and a feedback it receives. For each action, it will receive a reward, if the action was good or a penalty otherwise. Based on the knowledge the agent has gathered and the current state of the environment, the next action is chosen.
Python code just like in any other language requires testing. Unittest is a python framework dedicated for it. It has origins in Junit in terms of code structure and behavior. In this article I will try to illuminate a little bit the topic of testing in Python and provide some good practices.
It is impossible nowadays to not hear about microservices. It’s so “buzzy” word that everyone is talking, writing and thinking about it – either developers and managers. In this blogpost I’d like to focus on some useful cases concerning Python & Microservices altogether.
There are many ways to write code in order to achieve same results. This article will show you how different approaches affect the code execution in the scope of time duration. This should give you a hint on what choices should be made but mostly to encourage you to always consider time execution as a substantial matter.
While reading top-shelf Python books, you probably might have bumped into the sentence "be pythonic". But what exactly does it mean and how to use it in real life examples? This article presents some practical cases where pythonic approach should be used and shows you some code snippets, where this approach was implemented.
Python has many powerful and useful constructs. Depending on their design, they help us to write code safer, more readable, often faster and with lower memory usage. This article covers Iterables and Iterators, Generators, Context Managers, Comprehensions and Decorators and explains their usage and usability.
Mocking is just pretending to be and simulating specific behavior, we can replace our code’s parts with fake objects and verify how system behaves. At some point our system’s code starts to be complicated and have so many dependencies what makes it impossible to test without mocks. To cover all corner cases or to freely control our test scenario flow we have to simulate part of functionality – we have to force it to behave in exact way we want. For this purpose python uses unitest.mock library which is a standard library starting from Python 3.3 (for older versions installation is required).
In my professional career I used to write tests with both frameworks: unittest and pytest. Both are great tools with certain pros and cons, but pytest is significantly more popular these days. In this short blogpost I am going to share with you a couple of pytest’s features, that in my opinion, provide the answer for the heading question.