diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 364066e..160a9b9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,2 +1,7 @@ -FROM python -WORKDIR ~/ +FROM ubuntu:20.04 +WORKDIR / +RUN apt-get -y update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata +RUN apt-get install -y python3 python3-dev git python3-pip python3-kivy python-is-python3 libgl1-mesa-dev build-essential +RUN ln -s $(which pip3) /usr/bin/pip +RUN pip install pymongo pandas numpy scipy scikit-learn matplotlib pylint kivy \ No newline at end of file diff --git a/.devcontainer/dev-dockerfile b/.devcontainer/dev-dockerfile new file mode 100644 index 0000000..74659d4 --- /dev/null +++ b/.devcontainer/dev-dockerfile @@ -0,0 +1,2 @@ +FROM titanscout2022/tra-analysis-base:latest +WORKDIR / \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a14a6fb..824072f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "TRA Analysis Development Environment", "build": { - "dockerfile": "Dockerfile", + "dockerfile": "dev-dockerfile", }, "settings": { "terminal.integrated.shell.linux": "/bin/bash", @@ -24,5 +24,5 @@ "ms-python.python", "waderyan.gitblame" ], - "postCreateCommand": "apt install vim -y ; pip install -r src/requirements.txt ; pip install pylint ; pip install tra-analysis; pip install pytest" -} \ No newline at end of file + "postCreateCommand": "/usr/bin/pip3 install -r /workspaces/tra-data-analysis/src/requirements.txt && /usr/bin/pip3 install --no-cache-dir pylint && /usr/bin/pip3 install pytest" + } \ No newline at end of file diff --git a/src/config.json b/src/config.json deleted file mode 100644 index b94d399..0000000 --- a/src/config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "max-threads": 0.5, - "team": "", - "competition": "", - "key": { - "database": "", - "tba": "" - }, - "statistics": { - "match": { - "balls-blocked": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-collected": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-lower-teleop": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-lower-auto": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-started": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-upper-teleop": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ], - "balls-upper-auto": [ - "basic_stats", - "historical_analysis", - "regression_linear", - "regression_logarithmic", - "regression_exponential", - "regression_polynomial", - "regression_sigmoidal" - ] - }, - "metric": { - "elo": { - "score": 1500, - "N": 400, - "K": 24 - }, - "gl2": { - "score": 1500, - "rd": 250, - "vol": 0.06 - }, - "ts": { - "mu": 25, - "sigma": 8.33 - } - }, - "pit": { - "wheel-mechanism": true, - "low-balls": true, - "high-balls": true, - "wheel-success": true, - "strategic-focus": true, - "climb-mechanism": true, - "attitude": true - } - } -} \ No newline at end of file diff --git a/src/requirements.txt b/src/requirements.txt index f95ca14..a8f7063 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -2,4 +2,18 @@ requests pymongo pandas tra-analysis + +dnspython +pyinstaller +requests +pymongo + +numpy +scipy +scikit-learn +six +matplotlib +pyparsing +pandas + kivy==2.0.0rc2 \ No newline at end of file diff --git a/src/superscript.py b/src/superscript.py index 4c147de..1f4b511 100644 --- a/src/superscript.py +++ b/src/superscript.py @@ -143,67 +143,67 @@ def main(): warnings.filterwarnings("ignore") -# while (True): + while (True): - current_time = time.time() - print("[OK] time: " + str(current_time)) + current_time = time.time() + print("[OK] time: " + str(current_time)) - config = load_config("red-alliance-analysis\data-analysis\config.json") - competition = config["competition"] - match_tests = config["statistics"]["match"] - pit_tests = config["statistics"]["pit"] - metrics_tests = config["statistics"]["metric"] - print("[OK] configs loaded") + config = load_config("config.json") + competition = config["competition"] + match_tests = config["statistics"]["match"] + pit_tests = config["statistics"]["pit"] + metrics_tests = config["statistics"]["metric"] + print("[OK] configs loaded") - print("[OK] starting threads") - cfg_max_threads = config["max-threads"] - sys_max_threads = os.cpu_count() - if cfg_max_threads > -sys_max_threads and cfg_max_threads < 0 : - alloc_processes = sys_max_threads + cfg_max_threads - elif cfg_max_threads > 0 and cfg_max_threads < 1: - alloc_processes = math.floor(cfg_max_threads * sys_max_threads) - elif cfg_max_threads > 1 and cfg_max_threads <= sys_max_threads: - alloc_processes = cfg_max_threads - elif cfg_max_threads == 0: - alloc_processes = sys_max_threads - else: - print("[Err] Invalid number of processes, must be between -" + str(sys_max_threads) + " and " + str(sys_max_threads)) - exit() - # exec_threads = Pool(processes = alloc_processes) - # print("[OK] " + str(alloc_processes) + " threads started") + print("[OK] starting threads") + cfg_max_threads = config["max-threads"] + sys_max_threads = os.cpu_count() + if cfg_max_threads > -sys_max_threads and cfg_max_threads < 0 : + alloc_processes = sys_max_threads + cfg_max_threads + elif cfg_max_threads > 0 and cfg_max_threads < 1: + alloc_processes = math.floor(cfg_max_threads * sys_max_threads) + elif cfg_max_threads > 1 and cfg_max_threads <= sys_max_threads: + alloc_processes = cfg_max_threads + elif cfg_max_threads == 0: + alloc_processes = sys_max_threads + else: + print("[Err] Invalid number of processes, must be between -" + str(sys_max_threads) + " and " + str(sys_max_threads)) + exit() + exec_threads = Pool(processes = alloc_processes) + print("[OK] " + str(alloc_processes) + " threads started") - apikey = config["key"]["database"] - tbakey = config["key"]["tba"] - print("[OK] loaded keys") + apikey = config["key"]["database"] + tbakey = config["key"]["tba"] + print("[OK] loaded keys") - previous_time = get_previous_time(apikey) - print("[OK] analysis backtimed to: " + str(previous_time)) + previous_time = get_previous_time(apikey) + print("[OK] analysis backtimed to: " + str(previous_time)) - print("[OK] loading data") - start = time.time() - match_data = load_match(apikey, competition) - pit_data = load_pit(apikey, competition) - print("[OK] loaded data in " + str(time.time() - start) + " seconds") + print("[OK] loading data") + start = time.time() + match_data = load_match(apikey, competition) + pit_data = load_pit(apikey, competition) + print("[OK] loaded data in " + str(time.time() - start) + " seconds") - print("[OK] running match stats") - start = time.time() - matchloop(apikey, competition, match_data, match_tests) - print("[OK] finished match stats in " + str(time.time() - start) + " seconds") + print("[OK] running match stats") + start = time.time() + matchloop(apikey, competition, match_data, match_tests) + print("[OK] finished match stats in " + str(time.time() - start) + " seconds") - print("[OK] running team metrics") - start = time.time() - metricloop(tbakey, apikey, competition, previous_time, metrics_tests) - print("[OK] finished team metrics in " + str(time.time() - start) + " seconds") + print("[OK] running team metrics") + start = time.time() + metricloop(tbakey, apikey, competition, previous_time, metrics_tests) + print("[OK] finished team metrics in " + str(time.time() - start) + " seconds") - print("[OK] running pit analysis") - start = time.time() - pitloop(apikey, competition, pit_data, pit_tests) - print("[OK] finished pit analysis in " + str(time.time() - start) + " seconds") - - set_current_time(apikey, current_time) - print("[OK] finished all tests, looping") + print("[OK] running pit analysis") + start = time.time() + pitloop(apikey, competition, pit_data, pit_tests) + print("[OK] finished pit analysis in " + str(time.time() - start) + " seconds") + + set_current_time(apikey, current_time) + print("[OK] finished all tests, looping") - # clear() + # clear() def clear(): diff --git a/src/superscript.spec b/src/superscript.spec new file mode 100644 index 0000000..b9f9ca7 --- /dev/null +++ b/src/superscript.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['superscript.py'], + pathex=['/workspaces/tra-data-analysis/src'], + binaries=[], + datas=[], + hiddenimports=[ + "dnspython", + "sklearn.utils._weight_vector", + "requests", + ], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='superscript', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True )