Skip to content

Commit

Permalink
feat: create makefile and fix basedir setting
Browse files Browse the repository at this point in the history
  • Loading branch information
senavs committed Sep 25, 2021
1 parent ba48bdb commit e847ccf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
help:
@echo "Disease spread simulation with cellular automaton"
@echo ""
@echo "COMMANDS"
@echo " help: application help"
@echo " compile: create executable"

compile:
pip install -r ./requirements.txt
pyinstaller -F ./simulation/__main__.py -n dss --hidden-import dotenv --clean -i ./icon.ico
chmod +x dist/dss
cat ./simulation.config > dist/simulation.config
Binary file added icon.ico
Binary file not shown.
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ kiwisolver==1.3.2
matplotlib==3.4.3
numpy==1.21.2
pandas==1.3.2
Pillow==8.3.2
pyparsing==2.4.7
python-dateutil==2.8.2
pytz==2021.1
six==1.16.0
imageio==2.9.0
pydantic[dotenv]==1.8.2
pyinstaller==4.5.1
pyinstaller==4.5.1
pynput==1.6.8
python-dotenv==0.19.0
File renamed without changes.
5 changes: 4 additions & 1 deletion simulation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
preventions_names.append(flag)
selected_preventions.append(PREVENTIONS[flag])

print(f'{datetime.now().isoformat()} {SIMULATION_UUID: <38} {", ".join(preventions_names if preventions_names else ["null"])}')
preventions = ", ".join(preventions_names if preventions_names else ["null"])
print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - start. preventions: {preventions}')

p = Progress(*selected_preventions)
p.progress()

print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - done. {p.current_time} days')
10 changes: 9 additions & 1 deletion simulation/automatos/progress.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from datetime import datetime

from simulation.automatos.board import Board
from simulation.core.subject import Subject
from simulation.report.printer import Printer
from simulation.core.prevention import SocialIsolation, Mask, Vaccine, PreventionEnum
from simulation.report.reporter import Reporter
from simulation.settings import prevention_settings
from simulation.settings import prevention_settings, SIMULATION_UUID

PREVS = {
'mask': [Mask, prevention_settings.MASK_PERC_ACTIVATION],
Expand Down Expand Up @@ -39,8 +41,13 @@ def progress(self):
self.activate_preventions()

self.record()
print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - images saved')

self.reporter.save()
print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - sheets saved')

self.printer.make_gif()
print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - gif saved')

def record(self):
self.current_time += 1
Expand All @@ -59,3 +66,4 @@ def activate_preventions(self):
continue

self.reporter.report_prevt(name, self.current_time)
print(f'{datetime.now().isoformat()} {SIMULATION_UUID} - {name} activated. {self.current_time} days')
10 changes: 5 additions & 5 deletions simulation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SimulationBaseSetting(BaseSettings):
class Config:
env_file = '.config'
env_file = 'simulation.config'
env_file_encoding = 'utf-8'


Expand Down Expand Up @@ -61,19 +61,19 @@ class ReportSettings(SimulationBaseSetting):

@property
def OUTPUT_BOARD_DIR(self) -> str: # noqa
return f'./results/{SIMULATION_UUID}/board'
return os.path.join(self.OUTPUT_BASE_DIR, f'results/{SIMULATION_UUID}/board')

@property
def OUTPUT_SHEET_DIR(self) -> str: # noqa
return f'./results/{SIMULATION_UUID}/sheet'
return os.path.join(self.OUTPUT_BASE_DIR, f'results/{SIMULATION_UUID}/sheet')

@property
def OUTPUT_GRAPH_DIR(self) -> str: # noqa
return f'./results/{SIMULATION_UUID}/graph'
return os.path.join(self.OUTPUT_BASE_DIR, f'results/{SIMULATION_UUID}/graph')

@property
def OUTPUT_GIF_DIR(self) -> str: # noqa
return f'./results/{SIMULATION_UUID}/gif'
return os.path.join(self.OUTPUT_BASE_DIR, f'results/{SIMULATION_UUID}/gif')

@property
def OUTPUT_BOARD_DIMENSION(self) -> tuple[int, int]: # noqa
Expand Down

0 comments on commit e847ccf

Please sign in to comment.