Skip to content

Commit d930646

Browse files
authored
JSON&Docker support (#15)
1 parent 112728c commit d930646

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1752
-318
lines changed

.dockerignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# CI
7+
.codeclimate.yml
8+
.travis.yml
9+
.taskcluster.yml
10+
11+
# Docker
12+
docker-compose.yml
13+
Dockerfile
14+
.docker
15+
.dockerignore
16+
17+
# Byte-compiled / optimized / DLL files
18+
**/__pycache__/
19+
**/*.py[cod]
20+
21+
# C extensions
22+
*.so
23+
24+
# Distribution / packaging
25+
.Python
26+
env/
27+
build/
28+
develop-eggs/
29+
dist/
30+
downloads/
31+
eggs/
32+
lib/
33+
lib64/
34+
parts/
35+
sdist/
36+
var/
37+
*.egg-info/
38+
.installed.cfg
39+
*.egg
40+
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.coverage
55+
.cache
56+
nosetests.xml
57+
coverage.xml
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Django stuff:
64+
*.log
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Virtual environment
73+
.env
74+
.venv/
75+
venv/
76+
77+
# PyCharm
78+
.idea
79+
80+
# Python mode for VIM
81+
.ropeproject
82+
**/.ropeproject
83+
84+
# Vim swap files
85+
**/*.swp
86+
87+
# VS Code
88+
.vscode/

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM python:3.12.9-slim-bookworm AS base
2+
3+
WORKDIR /app
4+
5+
ENV LANG=C.UTF-8
6+
ENV LC_ALL=C.UTF-8
7+
ENV PYTHONDONTWRITEBYTECODE=1
8+
ENV PYTHONFAULTHANDLER=1
9+
ENV PATH=/home/pysatluser/.local/bin:$PATH
10+
ENV POETRY_HOME=/opt/poetry
11+
12+
RUN apt-get update && apt-get install -y curl && \
13+
curl -sSL https://install.python-poetry.org | python - && \
14+
cd /usr/local/bin && \
15+
ln -s /opt/poetry/bin/poetry && \
16+
poetry config virtualenvs.create true
17+
18+
# Копируем файлы зависимостей
19+
COPY pyproject.toml ./
20+
21+
# Устанавливаем зависимости
22+
RUN poetry install --no-interaction --no-ansi
23+
24+
# Копируем остальные файлы
25+
COPY . .
26+
27+
ENTRYPOINT ["poetry", "run", "python", "-m", "stattest.main"]
28+
# Default to experiment mode
29+
CMD [ "experiment", "--config", "../../config_examples/config_example.json" ]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"generator_configuration": {
3+
"generators": [
4+
{
5+
"name": "ExponentialGenerator",
6+
"params": {
7+
"lam": 0.5
8+
}
9+
}
10+
],
11+
"sizes": [100, 200],
12+
"count": 1000,
13+
"threads": 1,
14+
"skip_if_exists": true,
15+
"clear_before": false,
16+
"skip_step": false,
17+
"show_progress": false,
18+
"listeners": [
19+
{
20+
"name": "TimeEstimationListener"
21+
}
22+
]
23+
},
24+
"test_configuration": {
25+
"tests": [
26+
{
27+
"name": "KolmogorovSmirnovWeibullGofStatistic"
28+
}
29+
],
30+
"threads": 8,
31+
"worker":
32+
{
33+
"name": "PowerCalculationWorker",
34+
"params": {
35+
"alpha": 0.05,
36+
"monte_carlo_count": 100000,
37+
"cv_store": {
38+
"name": "CriticalValueDbStore",
39+
"params": {
40+
"db_url": "sqlite:///weibull_experiment.sqlite"
41+
}
42+
},
43+
"hypothesis": {
44+
"name": "WeibullHypothesis"
45+
}
46+
}
47+
},
48+
"listeners": [
49+
{
50+
"name": "TimeEstimationListener"
51+
}
52+
]
53+
},
54+
"report_configuration": {
55+
"report_builder": {
56+
"name": "PdfPowerReportBuilder"
57+
},
58+
"listeners": []
59+
},
60+
"rvs_store":
61+
{
62+
"name": "RvsDbStore",
63+
"params":
64+
{
65+
"db_url": "sqlite:///weibull_experiment.sqlite"
66+
}
67+
},
68+
"result_store":
69+
{
70+
"name": "ResultDbStore",
71+
"params":
72+
{
73+
"db_url": "sqlite:///weibull_experiment.sqlite"
74+
}
75+
}
76+
}

config_examples/config_example_full.json

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"generator_configuration": {
3+
"generators": [
4+
{
5+
"name": "ExponentialGenerator",
6+
"params": {
7+
"lam": 0.5
8+
}
9+
}
10+
],
11+
"sizes": [100, 200],
12+
"count": 1000,
13+
"threads": 1,
14+
"listeners": [
15+
{
16+
"name": "TimeEstimationListener"
17+
}
18+
]
19+
},
20+
"test_configuration": {
21+
"tests": [
22+
{
23+
"name": "KSWeibullTest"
24+
}
25+
],
26+
"threads": 8,
27+
"worker":
28+
{
29+
"name": "PowerCalculationWorker",
30+
"params": {
31+
"alpha": 0.05,
32+
"monte_carlo_count": 100000,
33+
"cv_store": {
34+
"name": "CriticalValueDbStore",
35+
"params": {
36+
"db_url": "sqlite:///weibull_experiment.sqlite"
37+
}
38+
},
39+
"hypothesis": {
40+
"name": "WeibullHypothesis"
41+
}
42+
}
43+
},
44+
"listeners": [
45+
{
46+
"name": "TimeEstimationListener"
47+
}
48+
]
49+
},
50+
"report_configuration": {
51+
"report_builder": {
52+
"name": "PdfPowerReportBuilder"
53+
},
54+
"listeners": []
55+
},
56+
"rvs_store":
57+
{
58+
"name": "RvsDbStore",
59+
"params":
60+
{
61+
"db_url": "sqlite:///weibull_experiment.sqlite"
62+
}
63+
},
64+
"result_store":
65+
{
66+
"name": "ResultDbStore",
67+
"params":
68+
{
69+
"db_url": "sqlite:///weibull_experiment.sqlite"
70+
}
71+
}
72+
}

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
services:
3+
stattest:
4+
build:
5+
context: .
6+
# dockerfile: "./docker/Dockerfile.custom"
7+
restart: unless-stopped
8+
container_name: pysatl-experiment
9+
volumes:
10+
- "./user_data:/stattest/user_data"
11+
# Default command used when running `docker compose up`
12+
command: >
13+
experiment
14+
--logfile /stattest/user_data/logs/pysatl_experiment.log
15+
--config /stattest/user_data/config.json
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from stattest.experiment import Experiment
1111
from stattest.experiment.configuration.configuration import (
12-
AlternativeConfiguration,
1312
ExperimentConfiguration,
13+
GeneratorConfiguration,
1414
ReportConfiguration,
1515
TestConfiguration,
1616
)
@@ -23,7 +23,7 @@
2323
)
2424
from stattest.experiment.hypothesis import NormalHypothesis
2525
from stattest.experiment.listener.listeners import TimeEstimationListener
26-
from stattest.experiment.report.model import PdfPowerReportBuilder
26+
from stattest.experiment.report.builders import PdfPowerReportBuilder
2727
from stattest.experiment.test.worker import PowerCalculationWorker
2828
from stattest.persistence.db_store import CriticalValueDbStore, ResultDbStore, RvsDbStore
2929

@@ -67,7 +67,7 @@
6767
KolmogorovSmirnovNormalityGofStatistic(),
6868
]
6969

70-
alternatives_configuration = AlternativeConfiguration(
70+
alternatives_configuration = GeneratorConfiguration(
7171
alternatives, sizes, count=1_000, threads=generation_threads, listeners=listeners
7272
)
7373

generators/gen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from stattest.experiment.generator import AbstractRVSGenerator
33

44

5-
class BBBRVSGenerator(AbstractRVSGenerator):
6-
def __init__(self, a, b, **kwargs):
5+
class GeneratorTest(AbstractRVSGenerator):
6+
def __init__(self, a=1, b=2, **kwargs):
77
super().__init__(**kwargs)
88
self.a = a
99
self.b = b
1010

1111
def code(self):
12-
return super()._convert_to_code(["beta", self.a, self.b])
12+
return super()._convert_to_code(["generator_test", self.a, self.b])
1313

1414
def generate(self, size):
1515
return generate_beta(size=size, a=self.a, b=self.b)

0 commit comments

Comments
 (0)