Measurement & mixed states for quantum systems.
Notes on measurement for quantum systems.
Introducing a delay to allow proper connection between dockerized Postgres & Django web app in Travis CI.
EDIT: Code URL updated.
Code on my Github
If you see the following error in the Travis’s job log while attempting to test dockerized Django apps with Travis, it means that the postgres docker container has started but not yet ready to accept connections.
psycopg2.OperationalError: could not connect to server: Connection refused
539 Is the server running on host "db" (172.18.0.2) and accepting
540 TCP/IP connections on port 5432?
.
.
.
django.db.utils.OperationalError: could not connect to server: Connection
refused 587 Is the server running on host "db" (172.18.0.2) and accepting
588 TCP/IP connections on port 5432?
The command "docker-compose run web python manage.py test" exited with 1.
A solution for this issue is to introduce a delay until connection is ready before executing the test.
The delay has to be implemented in the docker-compose.yml
file before
migration & running of Django’s server shown below:
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; python3 manage.py migrate'
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; python3 manage.py runserver 0.0.0.0:8000'
Config files:
These are the relevant config files used in a Django project with the delay
introduced in the docker-compose.yml
file. The actual command to run the
test is in the .travis.yml
file.
The database configuration in settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'db',
'PORT': 5432,
#'PORT': 5433,
}
}
The Dockerfile
:
FROM python:3
WORKDIR /usr/src/app
ADD requirements.txt /usr/src/app
RUN pip install -r requirements.txt
ADD . /usr/src/app
The docker-compose.yml
file:
version: '3'
services:
db:
image: postgres
migration:
build: .
# command: python3 manage.py migrate
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; python3 manage.py migrate'
volumes:
- .:/usr/src/app
depends_on:
- db
web:
build: .
# command: python3 manage.py runserver 0.0.0.0:8000
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; python3 manage.py runserver 0.0.0.0:8000'
volumes:
- .:/usr/src/app
ports:
- "8000:8000"
depends_on:
- db
- migration
The .travis.yml
file:
language: python
python:
- 3.6
services:
- docker
# - postgres
install:
- pip install -r requirements.txt
#before_script:
# - psql -c 'create database testdb;' -U postgres
# - psql -c 'create database travisci;' -U postgres
script:
# - docker-compose build
# - docker-compose run web python manage.py migrate
- docker-compose run web python manage.py test
# - python manage.py test
After introducing the delay, this is the successful test output in Travis’s job log.
.
.
.
.......
528----------------------------------------------------------------------
529Ran 10 tests in 0.126s
530
531OK
532Destroying test database for alias 'default'...
533The command "docker-compose run web python manage.py test" exited with 0.
See this post in stackoverflow.
Notes on measurement for quantum systems.
Notes on quantum states as a generalization of classical probabilities.
The location of ray_results folder in colab when using RLlib &/or tune.
My attempt to implement a water down version of PBT (Population based training) for MARL (Multi-agent reinforcement learning).
Ray (0.8.2) RLlib trainer common config from:
How to calculate dimension of output from a convolution layer?
Changing Google drive directory in Colab.
Notes on the probability for linear regression (Bayesian)
Notes on the math for RNN back propagation through time(BPTT), part 2. The 1st derivative of \(h_t\) with respect to \(h_{t-1}\).
Notes on the math for RNN back propagation through time(BPTT).
Filter rows with same column values in a Pandas dataframe.
Building & testing custom Sagemaker RL container.
Demo setup for simple (reinforcement learning) custom environment in Sagemaker. This example uses Proximal Policy Optimization with Ray (RLlib).
Basic workflow of testing a Django & Postgres web app with Travis (continuous integration) & deployment to Heroku (continuous deployment).
Basic workflow of testing a dockerized Django & Postgres web app with Travis (continuous integration) & deployment to Heroku (continuous deployment).
Introducing a delay to allow proper connection between dockerized Postgres & Django web app in Travis CI.
Creating & seeding a random policy class in RLlib.
A custom MARL (multi-agent reinforcement learning) environment where multiple agents trade against one another in a CDA (continuous double auction).
This post demonstrate how setup & access Tensorflow graphs.
This post demonstrates how to create customized functions to bundle commands in a .bash_profile file on Mac.
This post documents my implementation of the Random Network Distillation (RND) with Proximal Policy Optimization (PPO) algorithm. (continuous version)
This post documents my implementation of the Distributed Proximal Policy Optimization (Distributed PPO or DPPO) algorithm. (Distributed continuous version)
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm (Distributed discrete version).
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm. (multi-threaded continuous version)
This post documents my implementation of the A3C (Asynchronous Advantage Actor Critic) algorithm (discrete). (multi-threaded discrete version)
This post demonstrates how to accumulate gradients with Tensorflow.
This post demonstrates a simple usage example of distributed Tensorflow with Python multiprocessing package.
This post documents my implementation of the N-step Q-values estimation algorithm.
This post demonstrates how to use the Python’s multiprocessing package to achieve parallel data generation.
This post provides a simple usage examples for common Numpy array manipulation.
This post documents my implementation of the Dueling Double Deep Q Network with Priority Experience Replay (Duel DDQN with PER) algorithm.
This post documents my implementation of the Dueling Double Deep Q Network (Dueling DDQN) algorithm.
This post documents my implementation of the Double Deep Q Network (DDQN) algorithm.
This post documents my implementation of the Deep Q Network (DQN) algorithm.