Skip to content

thetemplates/python-bml-pymc

Repository files navigation


Python Bayesian Machine Learning via PyMC




Environments

Remote Development

For this project/template, the remote development environment requires

An image is built via the command

docker build . --file .devcontainer/Dockerfile -t uncertainty

On success, the output of

docker images

should include


repository tag image id created size
uncertainty latest $\ldots$ $\ldots$ $\ldots$

Subsequently, run a container, i.e., an instance, of the image uncertainty via:


docker run --rm --gpus all -i -t -p 127.0.0.1:10000:8888 -w /app 
	--mount type=bind,src="$(pwd)",target=/app uncertainty

Herein, -p 10000:8888 maps the host port 10000 to container port 8888. Note, the container's working environment, i.e., -w, must be inline with this project's top directory. Additionally


Get the name of the container via:

docker ps --all

Never deploy a root container, study the production Dockerfile; cf. /.devcontainer/Dockerfile


Remote Development & Integrated Development Environments

An IDE (integrated development environment) is a helpful remote development tool. The IntelliJ IDEA set up involves connecting to a machine's Docker daemon, the steps are


  • Settings $\rightarrow$ Build, Execution, Deployment $\rightarrow$ Docker $\rightarrow$ WSL: {select the linux operating system}
  • View $\rightarrow$ Tool Window $\rightarrow$ Services
    Within the Containers section connect to the running instance of interest, or ascertain connection to the running instance of interest.

Visual Studio Code has its container attachment instructions; study Attach Container.



Code Analysis

The GitHub Actions script main.yml conducts code analysis within a Cloud GitHub Workspace. Depending on the script, code analysis may occur on push to any repository branch, or on push to a specific branch.

The sections herein outline remote code analysis.


pylint

The directive

pylint --generate-rcfile > .pylintrc

generates the dotfile .pylintrc of the static code analyser pylint. Analyse a directory via the command

python -m pylint --rcfile .pylintrc {directory}

The .pylintrc file of this template project has been amended to adhere to team norms, including

  • Maximum number of characters on a single line.

    max-line-length=127

  • Maximum number of lines in a module.

    max-module-lines=135


pytest & pytest coverage

Important

Within main.yml, enable pytest & pytest coverage via patterns akin to

  • pytest -o python_files=test_*
  • pytest --cov-report term-missing --cov src/data/... tests/data/...

Within a remote environment conduct apply/conduct a pytest via

python -m pytest ...

Replace the ellipses with, e.g., a file name.


flake8

For code & complexity analysis. A directive of the form

python -m flake8 --count --select=E9,F63,F7,F82 --show-source 
	--statistics src/{directory.name}

inspects issues in relation to logic (F7), syntax (Python E9, Flake F7), mathematical formulae symbols (F63), undefined variable names (F82). Additionally

python -m flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 
	--statistics src/{directory.name}

inspects complexity.



References

JAX


XLA (Accelerated Linear Algebra)


PyMC


Multiprocessing









About

Bayesian Machine Learning via PyMC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published