Skip to content

A base template for transformer dependent natural language processing via PyTorch

Notifications You must be signed in to change notification settings

thetemplates/python-dl-pytorch

Repository files navigation


A base template for transformer dependent natural language processing via PyTorch


For Transformers Dependent Natural Language Processing


For Transformers Dependent Natural Language Processing



Environments

Remote Development

For this Python project/template, the remote development environment requires

An image is built via the command

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

On success, the output of

docker images

should include


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

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


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

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 running instance of entities 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

The directive patterns

python -m pytest tests/{directory.name}/...py
pytest --cov-report term-missing  --cov src/{directory.name}/...py tests/{directory.name}/...py

for test and test coverage, respectively.


flake8

For code & complexity analysis. A directive of the form

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

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/...

inspects complexity.









About

A base template for transformer dependent natural language processing via PyTorch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published