From e3bda8e656ba4d1655e7db24a2aecade0cb56e33 Mon Sep 17 00:00:00 2001 From: AGawde05 Date: Thu, 15 Oct 2020 22:09:33 +0000 Subject: [PATCH 1/6] feat: created kivy gui boilerplate --- design.kv | 46 ++++++++++++++++++++++++++++++++++++++++++++++ main.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 design.kv create mode 100644 main.py diff --git a/design.kv b/design.kv new file mode 100644 index 0000000..26092f2 --- /dev/null +++ b/design.kv @@ -0,0 +1,46 @@ +: + GridLayout: + cols: 1 + GridLayout: + cols: 1 + padding: 15, 15 + spacing: 20, 20 + Label: + text: "User Login" + font_size: "20sp" + TextInput: + id: username + hint_text: "Username" + TextInput: + id: password + password: True + hint_text: "Password" + RelativeLayout: + Button: + text: "Login" + on_press: root.login(root.ids.username.text, root.ids.password.text) + size_hint: 0.3, 0.5 + pos_hint: {"center_x": 0.5, "center_y": 0.6} + Label: + id: login_wrong + text: "" + GridLayout: + cols: 2 + size_hint: 0.2, 0.2 + padding: 10, 10 + spacing: 10, 0 + Button: + text: "Forgot Password?" + background_color: 1, 1, 1, 0 + opacity: 1 if self.state == "normal" else 0.5 + color: 0.1, 0.7, 1, 1 + Button: + text: "Sign Up" + on_press: root.sign_up() + background_color: 1, 1, 1 , 0 + opacity: 1 if self.state == "normal" else 0.5 + color: 0.1, 0.7, 1, 1 + +: + HomeScreen: + name: "home_screen" diff --git a/main.py b/main.py new file mode 100644 index 0000000..8bf4029 --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +from kivy.app import App +from kivy.lang import Builder +from kivy.uix.screenmanager import ScreenManager , Screen +from kivy.animation import Animation +from hoverable import HoverBehavior +from kivy.uix.image import Image +from kivy.uix.behaviors import ButtonBehavior +import json +from datetime import datetime +import glob +from pathlib import Path +import random + +import superscript as ss + +Builder.load_file('design.kv') + +class HomeScreen(Screen): + # def sign_up(self): + # self.manager.transition.direction = "left" + # self.manager.current = "sign_up_screen" + + # def login(self, uname, pword): + # with open ("users.json") as file: + # users = json.load(file) + # if uname in users and users[uname]["password"] == pword: + # self.manager.transition.direction = "left" + # self.manager.current = "login_screen_success" + # else: + # self.ids.login_wrong.text = "Incorrect Username or Password" + + +class RootWidget(ScreenManager): + pass + +class MainApp(App): + def build(self): + return RootWidget() + +if __name__ == "__main__": + MainApp().run() \ No newline at end of file From b1e0e377c992216c50cfdbfeed76d92c5a3dce34 Mon Sep 17 00:00:00 2001 From: AGawde05 Date: Mon, 2 Nov 2020 16:49:12 -0600 Subject: [PATCH 2/6] feat: gui with placeholders --- design.kv | 179 ++++++++++++++++++++++++++++++++++++++++-------------- main.py | 47 +++++--------- 2 files changed, 148 insertions(+), 78 deletions(-) diff --git a/design.kv b/design.kv index 26092f2..beb08c4 100644 --- a/design.kv +++ b/design.kv @@ -1,46 +1,135 @@ -: - GridLayout: - cols: 1 - GridLayout: - cols: 1 - padding: 15, 15 - spacing: 20, 20 - Label: - text: "User Login" - font_size: "20sp" - TextInput: - id: username - hint_text: "Username" - TextInput: - id: password - password: True - hint_text: "Password" - RelativeLayout: - Button: - text: "Login" - on_press: root.login(root.ids.username.text, root.ids.password.text) - size_hint: 0.3, 0.5 - pos_hint: {"center_x": 0.5, "center_y": 0.6} - Label: - id: login_wrong - text: "" - GridLayout: - cols: 2 - size_hint: 0.2, 0.2 - padding: 10, 10 - spacing: 10, 0 - Button: - text: "Forgot Password?" - background_color: 1, 1, 1, 0 - opacity: 1 if self.state == "normal" else 0.5 - color: 0.1, 0.7, 1, 1 - Button: - text: "Sign Up" - on_press: root.sign_up() - background_color: 1, 1, 1 , 0 - opacity: 1 if self.state == "normal" else 0.5 - color: 0.1, 0.7, 1, 1 +BoxLayout: + orientation: "vertical" + + NavigationLayout: + ScreenManager: + id: screen_manager + HomeScreen: + name: "Home" + BoxLayout: + orientation: "vertical" + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] -: - HomeScreen: - name: "home_screen" + GridLayout: + cols: 1 + padding: 15, 15 + spacing: 20, 20 + MDTextFieldRect: + hint_text: "Console Log" + # size_hint: .8, None + # align: 'center' + # Widget: + SettingsScreen: + name: "Settings" + BoxLayout: + orientation: 'vertical' + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] + Widget: + InfoScreen: + name: "Info" + BoxLayout: + orientation: 'vertical' + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] + # GridLayout: + # cols: 2 + # padding: 15, 15 + # spacing: 20, 20 + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "DB Key:" + halign: 'center' + MDTextField: + hint_text: "placeholder" + pos_hint: {"center_y": .5} + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "TBA Key:" + halign: 'center' + MDTextField: + hint_text: "placeholder" + pos_hint: {"center_y": .5} + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "CPU Use:" + halign: 'center' + MDLabel: + text: "placeholder" + halign: 'center' + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "Network:" + halign: 'center' + MDLabel: + text: "placeholder" + halign: 'center' + Widget: + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "Progress" + halign: 'center' + MDProgressBar: + id: progress + value: 50 + + + + MDNavigationDrawer: + id: nav_drawer + BoxLayout: + orientation: "vertical" + padding: "8dp" + spacing: "8dp" + MDLabel: + text: "Titan Scouting" + font_style: "Button" + size_hint_y: None + height: self.texture_size[1] + + MDLabel: + text: "Data Analysis" + font_style: "Caption" + size_hint_y: None + height: self.texture_size[1] + ScrollView: + MDList: + OneLineAvatarListItem: + text: "Home" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "left" + screen_manager.current = "Home" + IconLeftWidget: + icon: "home" + + OneLineAvatarListItem: + text: "Settings" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "right" + # screen_manager.fade + screen_manager.current = "Settings" + IconLeftWidget: + icon: "cog" + OneLineAvatarListItem: + text: "Info" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "right" + # screen_manager.fade + screen_manager.current = "Info" + IconLeftWidget: + icon: "cog" \ No newline at end of file diff --git a/main.py b/main.py index 8bf4029..d0a9709 100644 --- a/main.py +++ b/main.py @@ -1,41 +1,22 @@ -from kivy.app import App from kivy.lang import Builder -from kivy.uix.screenmanager import ScreenManager , Screen -from kivy.animation import Animation -from hoverable import HoverBehavior -from kivy.uix.image import Image -from kivy.uix.behaviors import ButtonBehavior -import json -from datetime import datetime -import glob -from pathlib import Path -import random - -import superscript as ss - -Builder.load_file('design.kv') +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.screenmanager import ScreenManager, Screen +from kivymd.app import MDApp +# import superscript as ss class HomeScreen(Screen): - # def sign_up(self): - # self.manager.transition.direction = "left" - # self.manager.current = "sign_up_screen" - - # def login(self, uname, pword): - # with open ("users.json") as file: - # users = json.load(file) - # if uname in users and users[uname]["password"] == pword: - # self.manager.transition.direction = "left" - # self.manager.current = "login_screen_success" - # else: - # self.ids.login_wrong.text = "Incorrect Username or Password" - - -class RootWidget(ScreenManager): + pass +class SettingsScreen(Screen): + pass +class InfoScreen(Screen): pass -class MainApp(App): +class MyApp(MDApp): def build(self): - return RootWidget() + self.theme_cls.primary_palette = "Red" + return Builder.load_file("design.kv") + + if __name__ == "__main__": - MainApp().run() \ No newline at end of file + MyApp().run() \ No newline at end of file From e8e220f1bd989605871758b4d3cb59c518eed7dd Mon Sep 17 00:00:00 2001 From: AGawde05 Date: Mon, 2 Nov 2020 16:49:39 -0600 Subject: [PATCH 3/6] fix: changed config.json path --- superscript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superscript.py b/superscript.py index a3f0409..7236e67 100644 --- a/superscript.py +++ b/superscript.py @@ -148,7 +148,7 @@ def main(): current_time = time.time() print("[OK] time: " + str(current_time)) - config = load_config("config.json") + config = load_config("data-analysis/config.json") competition = config["competition"] match_tests = config["statistics"]["match"] pit_tests = config["statistics"]["pit"] From b214e2f7975c59f8544fad22e235ee46bce84f37 Mon Sep 17 00:00:00 2001 From: AGawde05 Date: Mon, 2 Nov 2020 17:14:26 -0600 Subject: [PATCH 4/6] style: spaces to tabs --- design.kv | 264 +++++++++++++++++++++++++++--------------------------- main.py | 14 +-- 2 files changed, 139 insertions(+), 139 deletions(-) diff --git a/design.kv b/design.kv index beb08c4..92ee291 100644 --- a/design.kv +++ b/design.kv @@ -1,135 +1,135 @@ BoxLayout: - orientation: "vertical" - - NavigationLayout: - ScreenManager: - id: screen_manager - HomeScreen: - name: "Home" - BoxLayout: - orientation: "vertical" - MDToolbar: - title: screen_manager.current - elevation: 10 - left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] + orientation: "vertical" + + NavigationLayout: + ScreenManager: + id: screen_manager + HomeScreen: + name: "Home" + BoxLayout: + orientation: "vertical" + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] - GridLayout: - cols: 1 - padding: 15, 15 - spacing: 20, 20 - MDTextFieldRect: - hint_text: "Console Log" - # size_hint: .8, None - # align: 'center' - # Widget: - SettingsScreen: - name: "Settings" - BoxLayout: - orientation: 'vertical' - MDToolbar: - title: screen_manager.current - elevation: 10 - left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] - Widget: - InfoScreen: - name: "Info" - BoxLayout: - orientation: 'vertical' - MDToolbar: - title: screen_manager.current - elevation: 10 - left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] - # GridLayout: - # cols: 2 - # padding: 15, 15 - # spacing: 20, 20 - BoxLayout: - orientation: "horizontal" - MDLabel: - text: "DB Key:" - halign: 'center' - MDTextField: - hint_text: "placeholder" - pos_hint: {"center_y": .5} - BoxLayout: - orientation: "horizontal" - MDLabel: - text: "TBA Key:" - halign: 'center' - MDTextField: - hint_text: "placeholder" - pos_hint: {"center_y": .5} - BoxLayout: - orientation: "horizontal" - MDLabel: - text: "CPU Use:" - halign: 'center' - MDLabel: - text: "placeholder" - halign: 'center' - BoxLayout: - orientation: "horizontal" - MDLabel: - text: "Network:" - halign: 'center' - MDLabel: - text: "placeholder" - halign: 'center' - Widget: - BoxLayout: - orientation: "horizontal" - MDLabel: - text: "Progress" - halign: 'center' - MDProgressBar: - id: progress - value: 50 - - - - MDNavigationDrawer: - id: nav_drawer - BoxLayout: - orientation: "vertical" - padding: "8dp" - spacing: "8dp" - MDLabel: - text: "Titan Scouting" - font_style: "Button" - size_hint_y: None - height: self.texture_size[1] + GridLayout: + cols: 1 + padding: 15, 15 + spacing: 20, 20 + MDTextFieldRect: + hint_text: "Console Log" + # size_hint: .8, None + # align: 'center' + # Widget: + SettingsScreen: + name: "Settings" + BoxLayout: + orientation: 'vertical' + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] + Widget: + InfoScreen: + name: "Info" + BoxLayout: + orientation: 'vertical' + MDToolbar: + title: screen_manager.current + elevation: 10 + left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]] + # GridLayout: + # cols: 2 + # padding: 15, 15 + # spacing: 20, 20 + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "DB Key:" + halign: 'center' + MDTextField: + hint_text: "placeholder" + pos_hint: {"center_y": .5} + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "TBA Key:" + halign: 'center' + MDTextField: + hint_text: "placeholder" + pos_hint: {"center_y": .5} + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "CPU Use:" + halign: 'center' + MDLabel: + text: "placeholder" + halign: 'center' + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "Network:" + halign: 'center' + MDLabel: + text: "placeholder" + halign: 'center' + Widget: + BoxLayout: + orientation: "horizontal" + MDLabel: + text: "Progress" + halign: 'center' + MDProgressBar: + id: progress + value: 50 + + + + MDNavigationDrawer: + id: nav_drawer + BoxLayout: + orientation: "vertical" + padding: "8dp" + spacing: "8dp" + MDLabel: + text: "Titan Scouting" + font_style: "Button" + size_hint_y: None + height: self.texture_size[1] - MDLabel: - text: "Data Analysis" - font_style: "Caption" - size_hint_y: None - height: self.texture_size[1] - ScrollView: - MDList: - OneLineAvatarListItem: - text: "Home" - on_press: - # nav_drawer.set_state("close") - # screen_manager.transition.direction = "left" - screen_manager.current = "Home" - IconLeftWidget: - icon: "home" - - OneLineAvatarListItem: - text: "Settings" - on_press: - # nav_drawer.set_state("close") - # screen_manager.transition.direction = "right" - # screen_manager.fade - screen_manager.current = "Settings" - IconLeftWidget: - icon: "cog" - OneLineAvatarListItem: - text: "Info" - on_press: - # nav_drawer.set_state("close") - # screen_manager.transition.direction = "right" - # screen_manager.fade - screen_manager.current = "Info" - IconLeftWidget: - icon: "cog" \ No newline at end of file + MDLabel: + text: "Data Analysis" + font_style: "Caption" + size_hint_y: None + height: self.texture_size[1] + ScrollView: + MDList: + OneLineAvatarListItem: + text: "Home" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "left" + screen_manager.current = "Home" + IconLeftWidget: + icon: "home" + + OneLineAvatarListItem: + text: "Settings" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "right" + # screen_manager.fade + screen_manager.current = "Settings" + IconLeftWidget: + icon: "cog" + OneLineAvatarListItem: + text: "Info" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "right" + # screen_manager.fade + screen_manager.current = "Info" + IconLeftWidget: + icon: "cog" \ No newline at end of file diff --git a/main.py b/main.py index d0a9709..3e506cc 100644 --- a/main.py +++ b/main.py @@ -5,18 +5,18 @@ from kivymd.app import MDApp # import superscript as ss class HomeScreen(Screen): - pass + pass class SettingsScreen(Screen): - pass + pass class InfoScreen(Screen): - pass + pass class MyApp(MDApp): - def build(self): - self.theme_cls.primary_palette = "Red" - return Builder.load_file("design.kv") + def build(self): + self.theme_cls.primary_palette = "Red" + return Builder.load_file("design.kv") if __name__ == "__main__": - MyApp().run() \ No newline at end of file + MyApp().run() \ No newline at end of file From 4dd9786c042ecd3287a4a7bdc96474989640b819 Mon Sep 17 00:00:00 2001 From: ltcptgeneral Date: Mon, 2 Nov 2020 16:12:13 -0800 Subject: [PATCH 5/6] migrated to ubuntu Signed-off-by: ltcptgeneral --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 58d1bd3..47fbe3c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ requests pymongo -pandas -tra-analysis \ No newline at end of file +pandas \ No newline at end of file From 29d4002dc07cf9d51edcd7af312578c7d3dcde25 Mon Sep 17 00:00:00 2001 From: AGawde05 Date: Thu, 1 Apr 2021 02:21:01 -0500 Subject: [PATCH 6/6] feat: gui layout + basic func --- config.json | 123 +++++++++++++++++++++++++++++++++++-------------- design.kv | 22 +++++++-- main.py | 38 ++++++++++++++- superscript.py | 108 +++++++++++++++++++++---------------------- 4 files changed, 199 insertions(+), 92 deletions(-) diff --git a/config.json b/config.json index f143132..68d73d1 100644 --- a/config.json +++ b/config.json @@ -1,46 +1,101 @@ { "max-threads": 0.5, "team": "", - "competition": "", - "key":{ - "database":"", - "tba":"" + "competition": "2020ilch", + "key": { + "database": "mongodb+srv://analysis:MU2gPeEjEurRt2n@2022-scouting-4vfuu.mongodb.net/?retryWrites=true&w=majority", + "tba": "UDvKmPjPRfwwUdDX1JxbmkyecYBJhCtXeyVk9vmO2i7K0Zn4wqQPMfzuEINXJ7e5" }, - "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_analyss","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"] - + "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_analyss", + "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 + "metric": { + "elo": { + "score": 1500, + "N": 400, + "K": 24 }, - "gl2":{ - "score":1500, - "rd":250, - "vol":0.06 + "gl2": { + "score": 1500, + "rd": 250, + "vol": 0.06 }, - "ts":{ - "mu":25, - "sigma":8.33 + "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 + "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/design.kv b/design.kv index 92ee291..177a926 100644 --- a/design.kv +++ b/design.kv @@ -1,4 +1,4 @@ -BoxLayout: +: orientation: "vertical" NavigationLayout: @@ -51,6 +51,7 @@ BoxLayout: MDTextField: hint_text: "placeholder" pos_hint: {"center_y": .5} + BoxLayout: orientation: "horizontal" MDLabel: @@ -84,9 +85,15 @@ BoxLayout: MDProgressBar: id: progress value: 50 - + StatsScreen: + name: "Stats" + MDCheckbox: + size_hint: None, None + size: "48dp", "48dp" + pos_hint: {'center_x': .5, 'center_y': .5} + on_active: Screen.test() - +#Navigation Drawer ------------------------- MDNavigationDrawer: id: nav_drawer BoxLayout: @@ -131,5 +138,14 @@ BoxLayout: # screen_manager.transition.direction = "right" # screen_manager.fade screen_manager.current = "Info" + IconLeftWidget: + icon: "cog" + OneLineAvatarListItem: + text: "Stats" + on_press: + # nav_drawer.set_state("close") + # screen_manager.transition.direction = "right" + # screen_manager.fade + screen_manager.current = "Stats" IconLeftWidget: icon: "cog" \ No newline at end of file diff --git a/main.py b/main.py index 3e506cc..a57421e 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,40 @@ from kivy.lang import Builder + +from kivymd.uix.screen import Screen +from kivymd.uix.list import OneLineListItem, MDList, TwoLineListItem, ThreeLineListItem +from kivymd.uix.list import OneLineIconListItem, IconLeftWidget +from kivy.uix.scrollview import ScrollView + + from kivy.uix.boxlayout import BoxLayout from kivy.uix.screenmanager import ScreenManager, Screen +from kivy.uix.dropdown import DropDown +from kivy.uix.button import Button +from kivy.base import runTouchApp +from kivymd.uix.menu import MDDropdownMenu, MDMenuItem + from kivymd.app import MDApp # import superscript as ss +# from tra_analysis import analysis as an +import data as d +from collections import defaultdict +import json +import math +import numpy as np +import os +from os import system, name +from pathlib import Path +from multiprocessing import Pool +import matplotlib.pyplot as plt +from concurrent.futures import ThreadPoolExecutor +import time +import warnings + +# global exec_threads + + +# Screens class HomeScreen(Screen): pass class SettingsScreen(Screen): @@ -11,11 +42,16 @@ class SettingsScreen(Screen): class InfoScreen(Screen): pass +class StatsScreen(Screen): + pass + + class MyApp(MDApp): def build(self): self.theme_cls.primary_palette = "Red" return Builder.load_file("design.kv") - + def test(): + print("test") if __name__ == "__main__": diff --git a/superscript.py b/superscript.py index 7236e67..4c147de 100644 --- a/superscript.py +++ b/superscript.py @@ -135,75 +135,75 @@ from concurrent.futures import ThreadPoolExecutor import time import warnings -global exec_threads +# global exec_threads def main(): - global exec_threads + # global exec_threads 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("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("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") - 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(): @@ -314,7 +314,7 @@ def matchloop(apikey, competition, data, tests): # expects 3D array with [Team][ variable_data.append((data[team][variable], test)) test_filtered.append(test) - result_filtered = exec_threads.map(simplestats, variable_data) + result_filtered = map(simplestats, variable_data) i = 0 result_filtered = list(result_filtered)