new version of WID - 0.9

This commit is contained in:
bluxmit 2021-09-09 21:13:30 +00:00
parent ee5dc0601f
commit c850900e28
8 changed files with 126 additions and 5 deletions

View file

@ -0,0 +1,17 @@
ARG docker_registry=docker.io/alnoda
ARG image_tag=18.04-0.9
FROM ${docker_registry}/workspace-in-docker:${image_tag}
USER root
COPY python-requirements.txt /home/abc/installed-python-packages
COPY ./examples/ /home/examples/
RUN pip install -r /home/abc/installed-python-packages/python-requirements.txt \
&& echo "------------------------------------------------------ user" \
&& chown -R abc /home/abc/installed-python-packages \
&& find /home -type d | xargs -I{} chown -R abc {} \
&& find /home -type f | xargs -I{} chown abc {}
USER abc

View file

@ -0,0 +1,2 @@

View file

@ -0,0 +1,12 @@
# Basic python script
Boilerplate for the most simple python scripts
```sh
mv /home/examples/basic-python-script /home/project
```
```sh
mkdir -p /home/static-server/profiling/basic-python-script
pyinstrument -t -r html -o /home/static-server/profiling/basic-python-script/p2 script.py
```

View file

@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""
Example of tiny python script that calculates mean from the list of numbers
Select any line of python script and evaluate with Shift + Enter
Execute the whole script from terminal:
>> python app.py
Run tests with generation of HTML report:
>> pytest --html-report=/home/static-server/tests/basic-python-app
"""
from logzero import logger
numbers_1 = [1, 12, 53, 22, 41, 84]
numbers_2 = [31, 65, 84, 212, 4, 48, 54, 67, 20]
def calc_result(numbers):
""" Calculate average of numbers """
return sum(numbers) / len(numbers)
def write_to_file(file_name, numbers, result):
""" Write computation results to file """
with open(f"/home/examples/{file_name}.txt", "w") as file:
file.write(f"NUMBERS: {str(numbers)}")
file.write(f"\nAVERAGE: {str(result)}")
def main():
""" Main entry point of the app """
logger.info("start calculation")
result_1 = calc_result(numbers_1)
write_to_file("result_1", numbers_1, result_1)
result_2 = calc_result(numbers_2)
write_to_file("result_2", numbers_2, result_2)
logger.info("finish calculation")
if __name__ == "__main__":
""" This is executed when run from the command line """
main()

View file

@ -0,0 +1,21 @@
"""
You can auto-discover and run all tests with this command:
py.test
Documentation: https://docs.pytest.org/en/latest/
"""
from app import calc_result
def test_1():
test_numbers = [1, 1, 1, 1]
expected_result =1
assert calc_result(test_numbers) == expected_result
def test2():
test_numbers = [2, 3, 3, 4]
expected_result = 3
assert calc_result(test_numbers) == expected_result

View file

@ -0,0 +1,19 @@
# https://pypi.org/project/ipython/
ipython==7.27.0
# https://pypi.org/project/prettyprinter/
prettyprinter==0.18.0
# https://github.com/antonbabenko/pre-commit-terraform
pre-commit==2.14.0
## dev, test, lint
poetry==1.1.6
black==21.5b2
isort==5.8.0
flake8==3.9.2
mypy==0.812
pytest==6.2.4
pytest-regressions==2.2.0
pytest-html-reporter==0.2.6
logzero==1.7.0
pyinstrument==3.4.2
pylint==2.10.2

View file

@ -100,20 +100,22 @@
"vscode-builtin-xml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/xml-1.39.1-prel.vsix",
"vscode-builtin-yaml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/yaml-1.39.1-prel.vsix",
"vscode-editorconfig": "https://github.com/theia-ide/editorconfig-vscode/releases/download/v0.14.4/EditorConfig-0.14.4.vsix",
"vscode-python": "https://github.com/microsoft/vscode-python/releases/download/2020.1.58038/ms-python-release.vsix",
"vscode-python": "https://open-vsx.org/api/ms-python/python/2020.8.105369/file/ms-python.python-2020.8.105369.vsix",
"nadim-vscode.infinity-dark-theme": "https://open-vsx.org/api/nadim-vscode/infinity-dark-theme/1.0.1/file/nadim-vscode.infinity-dark-theme-1.0.1.vsix",
"emroussel.atomize-atom-one-dark-theme": "https://open-vsx.org/api/emroussel/atomize-atom-one-dark-theme/1.5.5/file/emroussel.atomize-atom-one-dark-theme-1.5.5.vsix",
"mhutchie.git-graph": "https://open-vsx.org/api/mhutchie/git-graph/1.30.0/file/mhutchie.git-graph-1.30.0.vsix",
"teabyii.ayu": "https://open-vsx.org/api/teabyii/ayu/0.20.1/file/teabyii.ayu-0.20.1.vsix",
"yurihs.sublime-vscode-theme": "https://open-vsx.org/api/yurihs/sublime-vscode-theme/1.4.1/file/yurihs.sublime-vscode-theme-1.4.1.vsix",
"wesbos.theme-cobalt2": "https://open-vsx.org/api/wesbos/theme-cobalt2/2.1.6/file/wesbos.theme-cobalt2-2.1.6.vsix",
"robbowen.synthwave-vscode": "https://open-vsx.org/api/RobbOwen/synthwave-vscode/0.1.8/file/RobbOwen.synthwave-vscode-0.1.8.vsix",
"github.github-vscode-theme": "https://open-vsx.org/api/GitHub/github-vscode-theme/4.1.1/file/GitHub.github-vscode-theme-4.1.1.vsix",
"armandphilippot.coldark": "https://open-vsx.org/api/armandphilippot/coldark/1.2.9/file/armandphilippot.coldark-1.2.9.vsix",
"radiolevity.search-lights": "https://open-vsx.org/api/radiolevity/search-lights/1.10.1/file/radiolevity.search-lights-1.10.1.vsix",
"vladeeg.vscode-theme-vlight": "https://open-vsx.org/api/Vladeeg/vscode-theme-vlight/2.1.0/file/Vladeeg.vscode-theme-vlight-2.1.0.vsix",
"akamud.vscode-theme-onelight": "https://open-vsx.org/api/akamud/vscode-theme-onelight/2.2.3/file/akamud.vscode-theme-onelight-2.2.3.vsix",
"akamud.vscode-theme-onedark": "https://open-vsx.org/api/akamud/vscode-theme-onedark/2.2.3/file/akamud.vscode-theme-onedark-2.2.3.vsix"
"akamud.vscode-theme-onedark": "https://open-vsx.org/api/akamud/vscode-theme-onedark/2.2.3/file/akamud.vscode-theme-onedark-2.2.3.vsix",
"daylerees.rainglow": "https://open-vsx.org/api/daylerees/rainglow/1.5.2/file/daylerees.rainglow-1.5.2.vsix",
"emroussel.atom-icons": "https://open-vsx.org/api/emroussel/atom-icons/1.2.0/file/emroussel.atom-icons-1.2.0.vsix",
"laurenttreguier.vscode-simple-icons": "https://open-vsx.org/api/LaurentTreguier/vscode-simple-icons/1.16.0/file/LaurentTreguier.vscode-simple-icons-1.16.0.vsix",
"technicolor-creamsicle.deepdark-material": "https://open-vsx.org/api/technicolor-creamsicle/deepdark-material/3.3.0/file/technicolor-creamsicle.deepdark-material-3.3.0.vsix"
}
}

View file

@ -13,7 +13,7 @@ nav:
# ===========================================================
site_name: My Workspace
repo_url: https://github.com/Alnoda/workspaces-in-docker/tree/main/workspaces/base-workspace
repo_url: https://github.com/bluxmit/alnoda-workspaces
site_url: https://alnoda.org
edit_uri: ""