opengamedata-api-files 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: opengamedata-api-files
3
+ Version: 2.0.0
4
+ Summary: A small collection of classes for deserializing data from the OpenGameData File API.
5
+ Author: Ryan Wilkinson
6
+ Author-email: Luke Swanson <lwswanson2@wisc.edu>, David Gagnon <djgagnon@wisc.edu>
7
+ Project-URL: Homepage, https://github.com/opengamedata/opengamedata-api-files
8
+ Project-URL: Bug Tracker, https://github.com/opengamedata/opengamedata-api-files/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: opengamedata-common==2.0.*
15
+ Requires-Dist: opengamedata-api-utils==1.5.*
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = [
3
+ "build == 1.2.*",
4
+ "setuptools == 74.1.*",
5
+ "setuptools-git-versioning == 2.0.*",
6
+ "twine == 5.1.*",
7
+ "wheel == 0.44.*"
8
+ ]
9
+ build-backend = "setuptools.build_meta"
10
+
11
+ [tool.setuptools]
12
+ packages = ["ogd.apis.models.files"]
13
+
14
+ [tool.setuptools.package-dir]
15
+ "" = "src"
16
+
17
+ [tool.setuptools-git-versioning]
18
+ enabled = true
19
+
20
+ [tool.setuptools.dynamic]
21
+ dependencies = {file = ["requirements.txt"]}
22
+
23
+ [project]
24
+ name = "opengamedata-api-files"
25
+ dynamic = ["version", "dependencies"]
26
+ authors = [
27
+ { name="Luke Swanson", email="lwswanson2@wisc.edu" },
28
+ { name="David Gagnon", email="djgagnon@wisc.edu" },
29
+ { name="Ryan Wilkinson" }
30
+ ]
31
+ description = "A small collection of classes for deserializing data from the OpenGameData File API."
32
+ readme = "README.md"
33
+ requires-python = ">=3.12"
34
+ classifiers = [
35
+ "Programming Language :: Python :: 3",
36
+ "License :: OSI Approved :: MIT License",
37
+ "Operating System :: OS Independent",
38
+ ]
39
+
40
+ [project.urls]
41
+ "Homepage" = "https://github.com/opengamedata/opengamedata-api-files"
42
+ "Bug Tracker" = "https://github.com/opengamedata/opengamedata-api-files/issues"
@@ -0,0 +1,2 @@
1
+ opengamedata-common==2.0.*
2
+ opengamedata-api-utils==1.5.*
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,71 @@
1
+ from typing import Final, List
2
+
3
+ from ogd.apis.models.APIResponse import APIResponse
4
+ from ogd.common.utils.typing import Map
5
+
6
+ class Dataset:
7
+ PATH : Final[str] = "/games/<string:game_id>/datasets/<int:year>"
8
+
9
+ def __init__(self, year:int, month:int, total_sessions:int,
10
+ sessions_file:str, players_file:str, population_file:str):
11
+ self._year = year
12
+ self._month = month
13
+ self._total_sessions = total_sessions
14
+ self._sessions_file = sessions_file
15
+ self._players_file = players_file
16
+ self._population_file = population_file
17
+
18
+ @property
19
+ def Year(self) -> int:
20
+ return self._year
21
+ @property
22
+ def Month(self) -> int:
23
+ return self._month
24
+ @property
25
+ def TotalSessions(self) -> int:
26
+ return self._total_sessions
27
+ @property
28
+ def SessionsFile(self) -> str:
29
+ return self._sessions_file
30
+ @property
31
+ def PlayersFile(self) -> str:
32
+ return self._players_file
33
+ @property
34
+ def PopulationFile(self) -> str:
35
+ return self._population_file
36
+
37
+ @property
38
+ def AsDict(self) -> Map:
39
+ return {
40
+ "year": self.Year,
41
+ "month": self.Month,
42
+ "total_sessions": self.TotalSessions,
43
+ "sessions_file": self.SessionsFile,
44
+ "players_file": self.PlayersFile,
45
+ "population_file": self.PopulationFile
46
+ }
47
+
48
+ @staticmethod
49
+ def FromAPIResponse(response:APIResponse) -> "Dataset":
50
+ """Parse a GameSummary from an APIResponse
51
+
52
+ :param response: The APIResponse object containing the GameSummary data.
53
+ :type response: APIResponse
54
+ :return: A GameSummary object constructed from the data given in the APIResponse
55
+ :rtype: GameSummary
56
+ """
57
+ ret_val : Dataset
58
+
59
+ if isinstance(response.Value, dict):
60
+ if all(key in response.Value.keys() for key in {"year", "month", "total_sessions", "sessions_file", "players_file", "population_file"}):
61
+ ret_val = Dataset(
62
+ year=response.Value.get("year", 0),
63
+ month=response.Value.get("month", 0),
64
+ total_sessions=response.Value.get("total_sessions", 0),
65
+ sessions_file=response.Value.get("sessions_file", "SESSIONS FILE NOT FOUND"),
66
+ players_file=response.Value.get("players_file", "PLAYERS FILE NOT FOUND"),
67
+ population_file=response.Value.get("population_file", "POPULATION FILE NOT FOUND"),
68
+ )
69
+ else:
70
+ raise ValueError(f"APIResponse for DatasetsYear had incorrect keys.")
71
+ return ret_val
@@ -0,0 +1,46 @@
1
+ from typing import Final, List
2
+
3
+ from ogd.apis.models.APIResponse import APIResponse
4
+ from ogd.common.utils.typing import Map
5
+
6
+ class DatasetFile:
7
+ PATH : Final[str] = "/games/<string:game_id>/datasets/<int:year>"
8
+
9
+ def __init__(self, columns:List, rows:List):
10
+ self._columns = columns
11
+ self._rows = rows
12
+
13
+ @property
14
+ def Columns(self) -> List:
15
+ return self._columns
16
+ @property
17
+ def Rows(self) -> List:
18
+ return self._rows
19
+
20
+ @property
21
+ def AsDict(self) -> Map:
22
+ return {
23
+ "columns": self.Columns,
24
+ "rows": self.Rows
25
+ }
26
+
27
+ @staticmethod
28
+ def FromAPIResponse(response:APIResponse) -> "DatasetFile":
29
+ """Parse a GameSummary from an APIResponse
30
+
31
+ :param response: The APIResponse object containing the GameSummary data.
32
+ :type response: APIResponse
33
+ :return: A GameSummary object constructed from the data given in the APIResponse
34
+ :rtype: GameSummary
35
+ """
36
+ ret_val : DatasetFile
37
+
38
+ if isinstance(response.Value, dict):
39
+ if all(key in response.Value.keys() for key in {"columns", "rows"}):
40
+ ret_val = DatasetFile(
41
+ columns=response.Value.get("columns", ["NO COLUMNS FOUND"]),
42
+ rows=response.Value.get("rows", ["NO ROWS FOUND"]),
43
+ )
44
+ else:
45
+ raise ValueError(f"APIResponse for DatasetFile had incorrect keys.")
46
+ return ret_val
@@ -0,0 +1,165 @@
1
+ from typing import Final, Optional
2
+
3
+ from ogd.apis.models.APIResponse import APIResponse
4
+ from ogd.common.schemas.datasets.DatasetSchema import DatasetSchema
5
+ from ogd.common.utils.typing import Map
6
+
7
+ class DatasetInfo:
8
+ PATH : Final[str] = "/games/<string:game_id>/datasets/<int:year>"
9
+
10
+ def __init__(self, first_year:int, first_month:int, last_year:int, last_month:int,
11
+ raw_file:Optional[str], events_file:Optional[str], sessions_file:Optional[str], players_file:Optional[str], population_file:Optional[str],
12
+ events_template:Optional[str], sessions_template:Optional[str], players_template:Optional[str], population_template:Optional[str],
13
+ events_codespace:Optional[str], sessions_codespace:Optional[str], players_codespace:Optional[str], population_codespace:Optional[str],
14
+ detectors_link:Optional[str], features_link:Optional[str], found_matching_range:bool):
15
+ self._first_year = first_year
16
+ self._first_month = first_month
17
+ self._last_year = last_year
18
+ self._last_month = last_month
19
+ self._raw_file = raw_file
20
+ self._events_file = events_file
21
+ self._sessions_file = sessions_file
22
+ self._players_file = players_file
23
+ self._population_file = population_file
24
+ self._events_template = events_template
25
+ self._sessions_template = sessions_template
26
+ self._players_template = players_template
27
+ self._population_template = population_template
28
+ self._events_codespace = events_codespace
29
+ self._sessions_codespace = sessions_codespace
30
+ self._players_codespace = players_codespace
31
+ self._population_codespace = population_codespace
32
+ self._detectors_link = detectors_link
33
+ self._features_link = features_link
34
+ self._found_matching_range = found_matching_range
35
+
36
+ @property
37
+ def FirstYear(self) -> int:
38
+ return self._first_year
39
+ @property
40
+ def FirstMonth(self) -> int:
41
+ return self._first_month
42
+ @property
43
+ def LastYear(self) -> int:
44
+ return self._last_year
45
+ @property
46
+ def LastMonth(self) -> int:
47
+ return self._last_month
48
+ @property
49
+ def RawFile(self) -> Optional[str]:
50
+ return self._raw_file
51
+ @property
52
+ def EventsFile(self) -> Optional[str]:
53
+ return self._events_file
54
+ @property
55
+ def SessionsFile(self) -> Optional[str]:
56
+ return self._sessions_file
57
+ @property
58
+ def PlayersFile(self) -> Optional[str]:
59
+ return self._players_file
60
+ @property
61
+ def PopulationFile(self) -> Optional[str]:
62
+ return self._population_file
63
+ @property
64
+ def EventsTemplate(self) -> Optional[str]:
65
+ return self._events_template
66
+ @property
67
+ def SessionsTemplate(self) -> Optional[str]:
68
+ return self._sessions_template
69
+ @property
70
+ def PlayersTemplate(self) -> Optional[str]:
71
+ return self._players_template
72
+ @property
73
+ def PopulationTemplate(self) -> Optional[str]:
74
+ return self._population_template
75
+ @property
76
+ def EventsCodespace(self) -> Optional[str]:
77
+ return self._events_codespace
78
+ @property
79
+ def SessionsCodespace(self) -> Optional[str]:
80
+ return self._sessions_codespace
81
+ @property
82
+ def PlayersCodespace(self) -> Optional[str]:
83
+ return self._players_codespace
84
+ @property
85
+ def PopulationCodespace(self) -> Optional[str]:
86
+ return self._population_codespace
87
+ @property
88
+ def DetectorsLink(self) -> Optional[str]:
89
+ return self._detectors_link
90
+ @property
91
+ def FeaturesLink(self) -> Optional[str]:
92
+ return self._features_link
93
+
94
+ @property
95
+ def AsDict(self) -> Map:
96
+ return {
97
+ "first_year": self.FirstYear,
98
+ "first_month": self.FirstMonth,
99
+ "last_year": self.LastYear,
100
+ "last_month": self.LastMonth,
101
+ "raw_file": self.RawFile,
102
+ "events_file": self.EventsFile,
103
+ "sessions_file": self.SessionsFile,
104
+ "players_file": self.PlayersFile,
105
+ "population_file": self.PopulationFile,
106
+ "events_template": self.EventsTemplate,
107
+ "sessions_template": self.SessionsTemplate,
108
+ "players_template": self.PlayersTemplate,
109
+ "population_template": self.PopulationTemplate,
110
+ "events_codespace": self.EventsCodespace,
111
+ "sessions_codespace": self.SessionsCodespace,
112
+ "players_codespace": self.PlayersCodespace,
113
+ "population_codespace": self.PopulationCodespace,
114
+ "detectors_link": self.DetectorsLink,
115
+ "features_link": self.FeaturesLink,
116
+ "found_matching_range": self._found_matching_range
117
+ }
118
+
119
+
120
+
121
+ @staticmethod
122
+ def FromAPIResponse(response:APIResponse) -> "DatasetInfo":
123
+ """Parse a GameSummary from an APIResponse
124
+
125
+ :param response: The APIResponse object containing the GameSummary data.
126
+ :type response: APIResponse
127
+ :return: A GameSummary object constructed from the data given in the APIResponse
128
+ :rtype: GameSummary
129
+ """
130
+ ret_val : DatasetInfo
131
+
132
+ if isinstance(response.Value, dict):
133
+ expected_keys = {
134
+ "first_year", "first_month", "last_year", "last_month",
135
+ "raw_file", "events_file", "sessions_file", "players_file", "population_file",
136
+ "events_template", "sessions_template", "players_template", "population_template",
137
+ "events_codespace", "sessions_codespace", "players_codespace", "population_codespace",
138
+ "detectors_link", "features_link", "found_matching_range"
139
+ }
140
+ if all(key in response.Value.keys() for key in expected_keys):
141
+ ret_val = DatasetInfo(
142
+ first_year=response.Value.get("first_year", 0),
143
+ first_month=response.Value.get("first_month", 0),
144
+ last_year=response.Value.get("last_year", 0),
145
+ last_month=response.Value.get("last_month", 0),
146
+ raw_file=response.Value.get("raw_file"),
147
+ events_file=response.Value.get("events_file"),
148
+ sessions_file=response.Value.get("sessions_file"),
149
+ players_file=response.Value.get("players_file"),
150
+ population_file=response.Value.get("population_file"),
151
+ events_template=response.Value.get("events_template"),
152
+ sessions_template=response.Value.get("sessions_template"),
153
+ players_template=response.Value.get("players_template"),
154
+ population_template=response.Value.get("population_template"),
155
+ events_codespace=response.Value.get("events_codespace"),
156
+ sessions_codespace=response.Value.get("sessions_codespace"),
157
+ players_codespace=response.Value.get("players_codespace"),
158
+ population_codespace=response.Value.get("population_codespace"),
159
+ detectors_link=response.Value.get("detectors_link"),
160
+ features_link=response.Value.get("features_link"),
161
+ found_matching_range=response.Value.get("found_matching_range", False)
162
+ )
163
+ else:
164
+ raise ValueError(f"APIResponse for DatasetInfo had incorrect keys.")
165
+ return ret_val
@@ -0,0 +1,40 @@
1
+ from typing import Final, List
2
+
3
+ from ogd.apis.models.APIResponse import APIResponse
4
+ from ogd.common.utils.typing import Map
5
+
6
+ class GameList:
7
+ PATH : Final[str] = "/games"
8
+
9
+ def __init__(self, game_ids:List[str]):
10
+ self._game_ids = game_ids
11
+
12
+ @property
13
+ def GameIDs(self) -> List[str]:
14
+ return self._game_ids
15
+
16
+ @property
17
+ def AsDict(self) -> Map:
18
+ return {
19
+ "game_ids": self.GameIDs
20
+ }
21
+
22
+ @staticmethod
23
+ def FromAPIResponse(response:APIResponse) -> "GameList":
24
+ """Parse a GameSummary from an APIResponse
25
+
26
+ :param response: The APIResponse object containing the GameSummary data.
27
+ :type response: APIResponse
28
+ :return: A GameSummary object constructed from the data given in the APIResponse
29
+ :rtype: GameSummary
30
+ """
31
+ ret_val : GameList
32
+
33
+ if isinstance(response.Value, dict):
34
+ if all(key in response.Value.keys() for key in {"game_ids"}):
35
+ ret_val = GameList(
36
+ game_ids=response.Value.get("game_ids", "GAMES NOT FOUND"),
37
+ )
38
+ else:
39
+ raise ValueError(f"APIResponse for GamesList had incorrect keys.")
40
+ return ret_val
@@ -0,0 +1,57 @@
1
+ from typing import Final, Optional
2
+ from ogd.apis.models.APIResponse import APIResponse
3
+ from ogd.common.utils.typing import Map
4
+
5
+ class GameSummary:
6
+ PATH : Final[str] = "/games/<string:game_id>"
7
+
8
+ def __init__(self, game_id:str, dataset_count:int, session_avg:Optional[int], initial_dataset:str):
9
+ self._game_id = game_id
10
+ self._dataset_count = dataset_count
11
+ self._session_avg = session_avg
12
+ self._initial_dataset = initial_dataset
13
+
14
+ @property
15
+ def GameID(self) -> str:
16
+ return self._game_id
17
+ @property
18
+ def DatasetCount(self) -> int:
19
+ return self._dataset_count
20
+ @property
21
+ def SessionAverage(self) -> Optional[int]:
22
+ return self._session_avg
23
+ @property
24
+ def InitialDataset(self) -> str:
25
+ return self._initial_dataset
26
+
27
+ @property
28
+ def AsDict(self) -> Map:
29
+ return {
30
+ "game_id": self.GameID,
31
+ "dataset_count": self.DatasetCount,
32
+ "session_average": self.SessionAverage,
33
+ "initial_dataset": self.InitialDataset
34
+ }
35
+
36
+ @staticmethod
37
+ def FromAPIResponse(response:APIResponse) -> "GameSummary":
38
+ """Parse a GameSummary from an APIResponse
39
+
40
+ :param response: The APIResponse object containing the GameSummary data.
41
+ :type response: APIResponse
42
+ :return: A GameSummary object constructed from the data given in the APIResponse
43
+ :rtype: GameSummary
44
+ """
45
+ ret_val : GameSummary
46
+
47
+ if isinstance(response.Value, dict):
48
+ if all(key in response.Value.keys() for key in {"game_id", "dataset_count", "session_average", "initial_dataset"}):
49
+ ret_val = GameSummary(
50
+ game_id=response.Value.get("game_id", "GAME NOT FOUND"),
51
+ dataset_count=response.Value.get("dataset_count", 0),
52
+ session_avg=response.Value.get("session_average", None),
53
+ initial_dataset=response.Value.get("initial_dataset", "DATASET NOT FOUND")
54
+ )
55
+ else:
56
+ raise ValueError(f"APIResponse for GameSummary had incorrect keys.")
57
+ return ret_val
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: opengamedata-api-files
3
+ Version: 2.0.0
4
+ Summary: A small collection of classes for deserializing data from the OpenGameData File API.
5
+ Author: Ryan Wilkinson
6
+ Author-email: Luke Swanson <lwswanson2@wisc.edu>, David Gagnon <djgagnon@wisc.edu>
7
+ Project-URL: Homepage, https://github.com/opengamedata/opengamedata-api-files
8
+ Project-URL: Bug Tracker, https://github.com/opengamedata/opengamedata-api-files/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: opengamedata-common==2.0.*
15
+ Requires-Dist: opengamedata-api-utils==1.5.*
@@ -0,0 +1,13 @@
1
+ pyproject.toml
2
+ requirements.txt
3
+ src/ogd/apis/models/files/Dataset.py
4
+ src/ogd/apis/models/files/DatasetFile.py
5
+ src/ogd/apis/models/files/DatasetInfo.py
6
+ src/ogd/apis/models/files/GameList.py
7
+ src/ogd/apis/models/files/GameSummary.py
8
+ src/ogd/apis/models/files/__init__.py
9
+ src/opengamedata_api_files.egg-info/PKG-INFO
10
+ src/opengamedata_api_files.egg-info/SOURCES.txt
11
+ src/opengamedata_api_files.egg-info/dependency_links.txt
12
+ src/opengamedata_api_files.egg-info/requires.txt
13
+ src/opengamedata_api_files.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ opengamedata-common==2.0.*
2
+ opengamedata-api-utils==1.5.*