hdforce 1.1.2__tar.gz → 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.
- {hdforce-1.1.2 → hdforce-2.0.0}/LICENSE.txt +1 -1
- {hdforce-1.1.2 → hdforce-2.0.0}/PKG-INFO +30 -21
- {hdforce-1.1.2 → hdforce-2.0.0}/README.md +146 -146
- {hdforce-1.1.2 → hdforce-2.0.0}/hdforce/AuthManager.py +189 -170
- {hdforce-1.1.2 → hdforce-2.0.0}/hdforce/Classes.py +83 -59
- hdforce-2.0.0/hdforce/CreateAthletes.py +90 -0
- hdforce-2.0.0/hdforce/GetAthletes.py +59 -0
- hdforce-2.0.0/hdforce/GetCOP.py +108 -0
- hdforce-2.0.0/hdforce/GetForceTime.py +133 -0
- hdforce-2.0.0/hdforce/GetForceTimeBulk.py +226 -0
- hdforce-2.0.0/hdforce/GetGroups.py +46 -0
- hdforce-2.0.0/hdforce/GetMetrics.py +56 -0
- hdforce-2.0.0/hdforce/GetTags.py +44 -0
- hdforce-2.0.0/hdforce/GetTeams.py +44 -0
- hdforce-2.0.0/hdforce/GetTests.py +305 -0
- hdforce-2.0.0/hdforce/GetTypes.py +34 -0
- {hdforce-1.1.2 → hdforce-2.0.0}/hdforce/LoggerConfig.py +53 -51
- hdforce-2.0.0/hdforce/UpdateAthletes.py +86 -0
- {hdforce-1.1.2 → hdforce-2.0.0}/hdforce/__init__.py +26 -21
- hdforce-2.0.0/hdforce/data/MetricDictionary.parquet +0 -0
- hdforce-2.0.0/hdforce/py.typed +0 -0
- {hdforce-1.1.2 → hdforce-2.0.0}/hdforce/utils.py +476 -333
- hdforce-2.0.0/pyproject.toml +67 -0
- hdforce-1.1.2/hdforce/CreateAthletes.py +0 -131
- hdforce-1.1.2/hdforce/GetAthletes.py +0 -122
- hdforce-1.1.2/hdforce/GetForceTime.py +0 -137
- hdforce-1.1.2/hdforce/GetGroups.py +0 -104
- hdforce-1.1.2/hdforce/GetMetrics.py +0 -115
- hdforce-1.1.2/hdforce/GetTags.py +0 -105
- hdforce-1.1.2/hdforce/GetTeams.py +0 -105
- hdforce-1.1.2/hdforce/GetTests.py +0 -245
- hdforce-1.1.2/hdforce/GetTestsAth.py +0 -177
- hdforce-1.1.2/hdforce/GetTestsGroup.py +0 -173
- hdforce-1.1.2/hdforce/GetTestsTeam.py +0 -172
- hdforce-1.1.2/hdforce/GetTestsType.py +0 -196
- hdforce-1.1.2/hdforce/GetTypes.py +0 -103
- hdforce-1.1.2/hdforce/UpdateAthletes.py +0 -130
- hdforce-1.1.2/pyproject.toml +0 -38
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hdforce
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Get your data from the Hawkin Dynamics API
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE.txt
|
|
7
|
+
Keywords: hawkin-dynamics,force-plate,sports-science,biomechanics,api-client,performance-data
|
|
7
8
|
Author: laureng-hd
|
|
8
9
|
Author-email: lauren@hawkindynamics.com
|
|
9
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
10
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience ::
|
|
12
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
13
16
|
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier:
|
|
19
|
-
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Dist: keyring (>=25.0.0,<26.0.0)
|
|
20
27
|
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
28
|
+
Requires-Dist: pyarrow (>=18.1,<25.0)
|
|
21
29
|
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
22
|
-
Requires-Dist:
|
|
30
|
+
Requires-Dist: pyjanitor (>=0.30,<0.31)
|
|
23
31
|
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
24
|
-
Requires-Dist: requests (>=2.
|
|
32
|
+
Requires-Dist: requests (>=2.33.0,<3.0.0)
|
|
25
33
|
Project-URL: Documentation, https://hawkindynamics.github.io/hawkinPy/
|
|
34
|
+
Project-URL: Homepage, https://www.hawkindynamics.com/
|
|
26
35
|
Project-URL: Repository, https://github.com/HawkinDynamics/hawkinPy
|
|
27
36
|
Description-Content-Type: text/markdown
|
|
28
37
|
|
|
29
|
-
# HDFORCE
|
|
38
|
+
# HDFORCE <img src="docs/img/hc-logo.png" align="right" alt="Hawkin Connect" width="120" />
|
|
30
39
|
|
|
31
40
|
|
|
32
41
|
**Get your data from the Hawkin Dynamics API**
|
|
@@ -42,7 +51,7 @@ Description-Content-Type: text/markdown
|
|
|
42
51
|
|
|
43
52
|
## How To Use The HDFORCE Package
|
|
44
53
|
|
|
45
|
-
HDFORCE provides simple functionality with Hawkin Dynamics API. These functions are for use with
|
|
54
|
+
HDFORCE provides simple functionality with Hawkin Dynamics API. These functions are for use with the Hawkin Dynamics API (spec v1.13+). You must be a Hawkin Dynamics user with an active integration account to utilize functions within the package.
|
|
46
55
|
|
|
47
56
|
## Functions
|
|
48
57
|
This API is designed to get data out of your Hawkin Dynamics server and interact with your data more intimately. It is not designed to be accessed from client applications directly. There is a limit on the amount of data that can be returned in a single request (256 MB). As your database grows, it will be necessary to use the `from_` and `to_` parameters to limit the size of the responses. Responses that exceed the memory limit will timeout and fail. It is advised that you design your client to handle this from the beginning. A recommended pattern would be to have two methods of fetching data. A scheduled pull that uses the `from_` and `to_` parameters to constrain the returned data to only tests that have occurred since the last fetch e.g. every day or every 5 minutes. And then a pull that fetches the entire database since you began testing that is only executed when necessary. A recommended way of doing this is to generate the `from_` and `to_` parameters for each month since you started and send a request for each either in parallel or sequentially.
|
|
@@ -99,7 +108,7 @@ While the purpose of the package is to help with accessing data specific to your
|
|
|
99
108
|
### Organization Specific Data
|
|
100
109
|
Every organization has data specific to them. With that, these entities will have unique IDs. It is important to have these IDs available to make the most of your test calls.
|
|
101
110
|
|
|
102
|
-
* `GetAthletes()` - Get the athletes for an account. Inactive players will only be included if `
|
|
111
|
+
* `GetAthletes()` - Get the athletes for an account. Inactive players will only be included if `includeInactive` = True. The response will be a data frame containing the athletes that match this query.
|
|
103
112
|
* `GetTeams()` - Get the team names and IDs for all the teams in the org. The response will be a data frame containing the teams that are in the organization.
|
|
104
113
|
* `GetGroups()` - Get the group names and IDs for all the groups in the org. The response will be a data frame containing the groups that are in the organization.
|
|
105
114
|
* `GetTags()` - Get the tag names, IDs, and descriptions for tags created by users in your org. The response will be a data frame.
|
|
@@ -114,15 +123,14 @@ value you will receive every test. This parameter is best suited for bulk export
|
|
|
114
123
|
you will receive every test from the beginning of time or the optionally supplied `from_`
|
|
115
124
|
parameter. This parameter is best suited for bulk exports of historical data
|
|
116
125
|
* `sync` = The result set will include updated and newly created tests, following the time constraints of `from_` and `to_`. This parameter is best suited to keep your database in sync with the Hawkin database. It cannot and should not be used to fetch your entire database. A recommended strategy would be to have a job that runs on a short interval e.g. every five minutes that sends the `lastSyncTime` that it received as the `from_` parameter with `sync=True`.
|
|
117
|
-
* `
|
|
126
|
+
* `includeInactive` = If False (default), only active tests are returned. Set to True to include inactive (disabled) trials in the result set.
|
|
118
127
|
|
|
119
128
|
#### Get Test Function
|
|
120
|
-
* `GetTests()` - Get the tests for your account. You can
|
|
121
|
-
* `GetTestsAth()` - Get only tests of the specified athlete from your organization. You can specify a time frame `from_`, or `to_`, which the tests should come (or be synced). Response will be a data frame containing the trials from the athlete, within the time range (if specified).
|
|
122
|
-
* `GetTestsType()` - Get only tests of the specified test type from your organization. You can specify a time frame `from_`, or `to_`, which the tests should come (or be synced). Response will be a data frame containing the trials from that test type, within the time range (if specified).
|
|
123
|
-
* `GetTestsTeam()` - Get only tests of the specified teams from your organization. Requires a `teamId` argument, which expects a text string, list or tuple (max of 10 teams). You can specify a time frame `from_`, or `to_`, which the tests should come (or be synced). Response will be a data frame containing the trials from those teams, within the time range (if specified).
|
|
124
|
-
* `GetTestsGroup()` - Get only tests of the specified groups from your organization. Requires a `groupId` argument, which expects a text string, list or tuple (max of 10 groups). You can specify a time frame `from_`, or `to_`, which the tests should come (or be synced). Response will be a data frame containing the trials from those groups, within the time range (if specified).
|
|
129
|
+
* `GetTests()` - Get the tests for your account. You can filter by `athleteId`, `typeId`, `teamId` (single or comma-separated list, max 10), or `groupId` (single or comma-separated list, max 10). You can also specify a time frame via `from_` / `to_` (or `sync=True` for incremental sync). Response will be a DataFrame containing the matching trials.
|
|
125
130
|
* `GetForceTime()` - Get the force-time data for a specific test by id. This includes both left, right and combined force data at 1000hz (per millisecond). Calculated velocity, displacement, and power at each time interval will also be included.
|
|
131
|
+
* `GetForceTimeBulk()` - Batch retrieval of force-time data for multiple test IDs. Supports optional export to csv, json, or parquet, plus de-identification of athlete fields.
|
|
132
|
+
|
|
133
|
+
*Note: the legacy `GetTestsAth`, `GetTestsType`, `GetTestsTeam`, and `GetTestsGroup` helpers were deprecated in hdforce v1.x and removed in v2.0.0. Use `GetTests()` with the corresponding `athleteId`, `typeId`, `teamId`, or `groupId` argument instead.*
|
|
126
134
|
|
|
127
135
|
## Examples
|
|
128
136
|
This is a basic example that shows a common workflow:
|
|
@@ -147,7 +155,8 @@ types
|
|
|
147
155
|
#### Get Athletes
|
|
148
156
|
``` Python
|
|
149
157
|
# Get Athletes
|
|
150
|
-
roster = hdforce.GetAthletes(
|
|
158
|
+
roster = hdforce.GetAthletes( includeInactive= False) # includeInactive defaults to False
|
|
159
|
+
|
|
151
160
|
|
|
152
161
|
# Athlete example
|
|
153
162
|
roster[roster['name'] =="Lauren Green"]
|
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
# HDFORCE
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
**Get your data from the Hawkin Dynamics API**
|
|
5
|
-
|
|
6
|
-
<!-- badges: start -->
|
|
7
|
-

|
|
8
|
-
[](https://github.com/HawkinDynamics/hawkinPy/actions/workflows/push-test.yml)
|
|
9
|
-

|
|
10
|
-
[](https://www.repostatus.org/#active)
|
|
11
|
-
[](https://www.tidyverse.org/lifecycle/#stable)
|
|
12
|
-
[](https://choosealicense.com/)
|
|
13
|
-
<!-- badges: end -->
|
|
14
|
-
|
|
15
|
-
## How To Use The HDFORCE Package
|
|
16
|
-
|
|
17
|
-
HDFORCE provides simple functionality with Hawkin Dynamics API. These functions are for use with
|
|
18
|
-
|
|
19
|
-
## Functions
|
|
20
|
-
This API is designed to get data out of your Hawkin Dynamics server and interact with your data more intimately. It is not designed to be accessed from client applications directly. There is a limit on the amount of data that can be returned in a single request (256 MB). As your database grows, it will be necessary to use the `from_` and `to_` parameters to limit the size of the responses. Responses that exceed the memory limit will timeout and fail. It is advised that you design your client to handle this from the beginning. A recommended pattern would be to have two methods of fetching data. A scheduled pull that uses the `from_` and `to_` parameters to constrain the returned data to only tests that have occurred since the last fetch e.g. every day or every 5 minutes. And then a pull that fetches the entire database since you began testing that is only executed when necessary. A recommended way of doing this is to generate the `from_` and `to_` parameters for each month since you started and send a request for each either in parallel or sequentially.
|
|
21
|
-
|
|
22
|
-
This package was meant to help execute requests to the Hawkin Dynamics API with a single line of code. There are 13 functions to help execute 4 primary objectives:
|
|
23
|
-
|
|
24
|
-
### Authentication
|
|
25
|
-
Use the Refresh Token generated by https://cloud.hawkindynamics.com/integrations to get a valid Access Token. Only the organization administrator account can generate API tokens. Use this function to initiate access to your data in the cloud. All other HDFORCE functions will depend on the values returned from this function.
|
|
26
|
-
|
|
27
|
-
In HDFORCE, we can create and manage your authentication settings with the `authManager` function. The arguments passed will be used to handle authentication for the other functions used in the program. With this function, you can control these settings:
|
|
28
|
-
|
|
29
|
-
* __region__: Sets the URL prefix of your cloud site.
|
|
30
|
-
* __authMethod__: Sets storage method of auth variables. One of env, file, or manual. Default to 'env'.
|
|
31
|
-
* __refreshToken_name__: Provide or set the name of the refresh Token variable. Default to "HD_REFRESH_TOKEN".
|
|
32
|
-
* __refreshToken__: Optionally provided to pass a token for authentication when authMethod="manual". Else it will set the refresh token value when provided.
|
|
33
|
-
* __env_file_name__: Required when authManager="file". Directs storage location of variables.
|
|
34
|
-
|
|
35
|
-
The authentication manager allows the user to manage authentication with various development strategies. The 'env' method was designed to allow for simple authentication while developing in a local or contained environment, where the refresh token and variables are stored in the system environment. The 'file' method can be used for more visible and dynamic interaction with the auth variables, as the refresh token and variables are stored with a .env file. While the 'manual' method allows for the use of the package without storing sensitive data, in so the refresh token is not stored and is only used for authentication. This could be helpful in the scenario of developing a password-protected application where the token can be used as a password.
|
|
36
|
-
|
|
37
|
-
In the case of the "file" method, the user will need to save a .env file in the source directory. When using this method, you will also need to pass the file name to the `env_file_name` argument as a string. It's most common to use something as simple as ".env", but you can name your file anything ending with .env.
|
|
38
|
-
|
|
39
|
-
Below is an example of what the .env file can look like. This can be used as a template, as the variable name "HD_REFRESH_TOKEN" is the default to what the `authManager` function will use for the `refreshToken_name`. If you want to use a different variable name, simply pass the string through the `refreshToken_name` argument, along with the token to the `refreshToken` argument. The other values for ACCESS_TOKEN, TOKEN_EXPIRATION, and CLOUD_URL are defaults within the `authManager` function and should be maintained.
|
|
40
|
-
|
|
41
|
-
``` PowerShell
|
|
42
|
-
# Inside your .env file
|
|
43
|
-
|
|
44
|
-
HD_REFRESH_TOKEN=your_api_token # Replace With Your Refresh Token
|
|
45
|
-
REGION=your_region # Replace With Your URL region
|
|
46
|
-
ACCESS_TOKEN= # Access token will be stored here
|
|
47
|
-
TOKEN_EXPIRATION= # Token Expiration will be stored here
|
|
48
|
-
CLOUD_URL= # Your region's URL here
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
With the variables stored, we can use them with our other functions without worrying about authentication for each call.
|
|
52
|
-
|
|
53
|
-
``` Python
|
|
54
|
-
# Run authentication manager
|
|
55
|
-
AuthManager(authMethod="env", region= "Americas")
|
|
56
|
-
|
|
57
|
-
# Run authentication manager with file method
|
|
58
|
-
AuthManager(authMethod="file", env_file_name=".env", region= "Americas")
|
|
59
|
-
|
|
60
|
-
# Run authentication manager with manual method
|
|
61
|
-
AuthManager(authMethod="manual", region="Americas", refreshToken="your_refresh_token")
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Hawkin Specific data
|
|
66
|
-
While the purpose of the package is to help with accessing data specific to your organization, it may be helpful to store some data that is specific to Hawkin and the Hawkin Dynamics system. Things like test types and test metrics will help you call your data more efficiently and better understand the values you are seeing.
|
|
67
|
-
|
|
68
|
-
* `GetTypes` - Get the test type names and IDs for all the test types in the system. The response will be a data frame containing the tests that are in the HD system.
|
|
69
|
-
* `GetMetrics` - Get all the metrics for each test type. The response will be a data frame containing the test canonical ID, test type name, metric ID, metric label, a metric unit of measure, and description.
|
|
70
|
-
|
|
71
|
-
### Organization Specific Data
|
|
72
|
-
Every organization has data specific to them. With that, these entities will have unique IDs. It is important to have these IDs available to make the most of your test calls.
|
|
73
|
-
|
|
74
|
-
* `GetAthletes()` - Get the athletes for an account. Inactive players will only be included if `
|
|
75
|
-
* `GetTeams()` - Get the team names and IDs for all the teams in the org. The response will be a data frame containing the teams that are in the organization.
|
|
76
|
-
* `GetGroups()` - Get the group names and IDs for all the groups in the org. The response will be a data frame containing the groups that are in the organization.
|
|
77
|
-
* `GetTags()` - Get the tag names, IDs, and descriptions for tags created by users in your org. The response will be a data frame.
|
|
78
|
-
|
|
79
|
-
### Get Test Data
|
|
80
|
-
This is what you are here for. These functions allow you to call test data most efficiently. It is encouraged that you take advantage of the `from_`, `to_`, and `sync` parameters. This will help prevent from having calls with large payloads that may timeout and fail.
|
|
81
|
-
|
|
82
|
-
#### Get Test Arguments
|
|
83
|
-
* `from_` = Optionally supply a time (Unix timestamp) you want the tests from. If you do not supply this
|
|
84
|
-
value you will receive every test. This parameter is best suited for bulk exports of historical data.
|
|
85
|
-
* `to_` = Optionally supply a time (Unix timestamp) you want the tests to. If you do not supply this value
|
|
86
|
-
you will receive every test from the beginning of time or the optionally supplied `from_`
|
|
87
|
-
parameter. This parameter is best suited for bulk exports of historical data
|
|
88
|
-
* `sync` = The result set will include updated and newly created tests, following the time constraints of `from_` and `to_`. This parameter is best suited to keep your database in sync with the Hawkin database. It cannot and should not be used to fetch your entire database. A recommended strategy would be to have a job that runs on a short interval e.g. every five minutes that sends the `lastSyncTime` that it received as the `from_` parameter with `sync=True`.
|
|
89
|
-
* `
|
|
90
|
-
|
|
91
|
-
#### Get Test Function
|
|
92
|
-
* `GetTests()` - Get the tests for your account. You can
|
|
93
|
-
* `
|
|
94
|
-
* `
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
#
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
# Athlete example
|
|
125
|
-
roster[roster['name'] =="Lauren Green"]
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
#### Get Tags
|
|
129
|
-
``` Python
|
|
130
|
-
# Get Tags
|
|
131
|
-
tags = hdforce.GetTags()
|
|
132
|
-
|
|
133
|
-
# Tags example
|
|
134
|
-
tags[0:6]
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Get Tests
|
|
138
|
-
``` Python
|
|
139
|
-
# Get Tags
|
|
140
|
-
allTests = hdforce.GetTests()
|
|
141
|
-
# Filter my tests
|
|
142
|
-
mytests = allTests[allTests['athlete.name'] =="Lauren Green"]
|
|
143
|
-
# Slice some rows and columns
|
|
144
|
-
df = mytests.iloc[:5,:15]
|
|
145
|
-
|
|
146
|
-
df
|
|
1
|
+
# HDFORCE <img src="docs/img/hc-logo.png" align="right" alt="Hawkin Connect" width="120" />
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
**Get your data from the Hawkin Dynamics API**
|
|
5
|
+
|
|
6
|
+
<!-- badges: start -->
|
|
7
|
+

|
|
8
|
+
[](https://github.com/HawkinDynamics/hawkinPy/actions/workflows/push-test.yml)
|
|
9
|
+

|
|
10
|
+
[](https://www.repostatus.org/#active)
|
|
11
|
+
[](https://www.tidyverse.org/lifecycle/#stable)
|
|
12
|
+
[](https://choosealicense.com/)
|
|
13
|
+
<!-- badges: end -->
|
|
14
|
+
|
|
15
|
+
## How To Use The HDFORCE Package
|
|
16
|
+
|
|
17
|
+
HDFORCE provides simple functionality with Hawkin Dynamics API. These functions are for use with the Hawkin Dynamics API (spec v1.13+). You must be a Hawkin Dynamics user with an active integration account to utilize functions within the package.
|
|
18
|
+
|
|
19
|
+
## Functions
|
|
20
|
+
This API is designed to get data out of your Hawkin Dynamics server and interact with your data more intimately. It is not designed to be accessed from client applications directly. There is a limit on the amount of data that can be returned in a single request (256 MB). As your database grows, it will be necessary to use the `from_` and `to_` parameters to limit the size of the responses. Responses that exceed the memory limit will timeout and fail. It is advised that you design your client to handle this from the beginning. A recommended pattern would be to have two methods of fetching data. A scheduled pull that uses the `from_` and `to_` parameters to constrain the returned data to only tests that have occurred since the last fetch e.g. every day or every 5 minutes. And then a pull that fetches the entire database since you began testing that is only executed when necessary. A recommended way of doing this is to generate the `from_` and `to_` parameters for each month since you started and send a request for each either in parallel or sequentially.
|
|
21
|
+
|
|
22
|
+
This package was meant to help execute requests to the Hawkin Dynamics API with a single line of code. There are 13 functions to help execute 4 primary objectives:
|
|
23
|
+
|
|
24
|
+
### Authentication
|
|
25
|
+
Use the Refresh Token generated by https://cloud.hawkindynamics.com/integrations to get a valid Access Token. Only the organization administrator account can generate API tokens. Use this function to initiate access to your data in the cloud. All other HDFORCE functions will depend on the values returned from this function.
|
|
26
|
+
|
|
27
|
+
In HDFORCE, we can create and manage your authentication settings with the `authManager` function. The arguments passed will be used to handle authentication for the other functions used in the program. With this function, you can control these settings:
|
|
28
|
+
|
|
29
|
+
* __region__: Sets the URL prefix of your cloud site.
|
|
30
|
+
* __authMethod__: Sets storage method of auth variables. One of env, file, or manual. Default to 'env'.
|
|
31
|
+
* __refreshToken_name__: Provide or set the name of the refresh Token variable. Default to "HD_REFRESH_TOKEN".
|
|
32
|
+
* __refreshToken__: Optionally provided to pass a token for authentication when authMethod="manual". Else it will set the refresh token value when provided.
|
|
33
|
+
* __env_file_name__: Required when authManager="file". Directs storage location of variables.
|
|
34
|
+
|
|
35
|
+
The authentication manager allows the user to manage authentication with various development strategies. The 'env' method was designed to allow for simple authentication while developing in a local or contained environment, where the refresh token and variables are stored in the system environment. The 'file' method can be used for more visible and dynamic interaction with the auth variables, as the refresh token and variables are stored with a .env file. While the 'manual' method allows for the use of the package without storing sensitive data, in so the refresh token is not stored and is only used for authentication. This could be helpful in the scenario of developing a password-protected application where the token can be used as a password.
|
|
36
|
+
|
|
37
|
+
In the case of the "file" method, the user will need to save a .env file in the source directory. When using this method, you will also need to pass the file name to the `env_file_name` argument as a string. It's most common to use something as simple as ".env", but you can name your file anything ending with .env.
|
|
38
|
+
|
|
39
|
+
Below is an example of what the .env file can look like. This can be used as a template, as the variable name "HD_REFRESH_TOKEN" is the default to what the `authManager` function will use for the `refreshToken_name`. If you want to use a different variable name, simply pass the string through the `refreshToken_name` argument, along with the token to the `refreshToken` argument. The other values for ACCESS_TOKEN, TOKEN_EXPIRATION, and CLOUD_URL are defaults within the `authManager` function and should be maintained.
|
|
40
|
+
|
|
41
|
+
``` PowerShell
|
|
42
|
+
# Inside your .env file
|
|
43
|
+
|
|
44
|
+
HD_REFRESH_TOKEN=your_api_token # Replace With Your Refresh Token
|
|
45
|
+
REGION=your_region # Replace With Your URL region
|
|
46
|
+
ACCESS_TOKEN= # Access token will be stored here
|
|
47
|
+
TOKEN_EXPIRATION= # Token Expiration will be stored here
|
|
48
|
+
CLOUD_URL= # Your region's URL here
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
With the variables stored, we can use them with our other functions without worrying about authentication for each call.
|
|
52
|
+
|
|
53
|
+
``` Python
|
|
54
|
+
# Run authentication manager
|
|
55
|
+
AuthManager(authMethod="env", region= "Americas")
|
|
56
|
+
|
|
57
|
+
# Run authentication manager with file method
|
|
58
|
+
AuthManager(authMethod="file", env_file_name=".env", region= "Americas")
|
|
59
|
+
|
|
60
|
+
# Run authentication manager with manual method
|
|
61
|
+
AuthManager(authMethod="manual", region="Americas", refreshToken="your_refresh_token")
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Hawkin Specific data
|
|
66
|
+
While the purpose of the package is to help with accessing data specific to your organization, it may be helpful to store some data that is specific to Hawkin and the Hawkin Dynamics system. Things like test types and test metrics will help you call your data more efficiently and better understand the values you are seeing.
|
|
67
|
+
|
|
68
|
+
* `GetTypes` - Get the test type names and IDs for all the test types in the system. The response will be a data frame containing the tests that are in the HD system.
|
|
69
|
+
* `GetMetrics` - Get all the metrics for each test type. The response will be a data frame containing the test canonical ID, test type name, metric ID, metric label, a metric unit of measure, and description.
|
|
70
|
+
|
|
71
|
+
### Organization Specific Data
|
|
72
|
+
Every organization has data specific to them. With that, these entities will have unique IDs. It is important to have these IDs available to make the most of your test calls.
|
|
73
|
+
|
|
74
|
+
* `GetAthletes()` - Get the athletes for an account. Inactive players will only be included if `includeInactive` = True. The response will be a data frame containing the athletes that match this query.
|
|
75
|
+
* `GetTeams()` - Get the team names and IDs for all the teams in the org. The response will be a data frame containing the teams that are in the organization.
|
|
76
|
+
* `GetGroups()` - Get the group names and IDs for all the groups in the org. The response will be a data frame containing the groups that are in the organization.
|
|
77
|
+
* `GetTags()` - Get the tag names, IDs, and descriptions for tags created by users in your org. The response will be a data frame.
|
|
78
|
+
|
|
79
|
+
### Get Test Data
|
|
80
|
+
This is what you are here for. These functions allow you to call test data most efficiently. It is encouraged that you take advantage of the `from_`, `to_`, and `sync` parameters. This will help prevent from having calls with large payloads that may timeout and fail.
|
|
81
|
+
|
|
82
|
+
#### Get Test Arguments
|
|
83
|
+
* `from_` = Optionally supply a time (Unix timestamp) you want the tests from. If you do not supply this
|
|
84
|
+
value you will receive every test. This parameter is best suited for bulk exports of historical data.
|
|
85
|
+
* `to_` = Optionally supply a time (Unix timestamp) you want the tests to. If you do not supply this value
|
|
86
|
+
you will receive every test from the beginning of time or the optionally supplied `from_`
|
|
87
|
+
parameter. This parameter is best suited for bulk exports of historical data
|
|
88
|
+
* `sync` = The result set will include updated and newly created tests, following the time constraints of `from_` and `to_`. This parameter is best suited to keep your database in sync with the Hawkin database. It cannot and should not be used to fetch your entire database. A recommended strategy would be to have a job that runs on a short interval e.g. every five minutes that sends the `lastSyncTime` that it received as the `from_` parameter with `sync=True`.
|
|
89
|
+
* `includeInactive` = If False (default), only active tests are returned. Set to True to include inactive (disabled) trials in the result set.
|
|
90
|
+
|
|
91
|
+
#### Get Test Function
|
|
92
|
+
* `GetTests()` - Get the tests for your account. You can filter by `athleteId`, `typeId`, `teamId` (single or comma-separated list, max 10), or `groupId` (single or comma-separated list, max 10). You can also specify a time frame via `from_` / `to_` (or `sync=True` for incremental sync). Response will be a DataFrame containing the matching trials.
|
|
93
|
+
* `GetForceTime()` - Get the force-time data for a specific test by id. This includes both left, right and combined force data at 1000hz (per millisecond). Calculated velocity, displacement, and power at each time interval will also be included.
|
|
94
|
+
* `GetForceTimeBulk()` - Batch retrieval of force-time data for multiple test IDs. Supports optional export to csv, json, or parquet, plus de-identification of athlete fields.
|
|
95
|
+
|
|
96
|
+
*Note: the legacy `GetTestsAth`, `GetTestsType`, `GetTestsTeam`, and `GetTestsGroup` helpers were deprecated in hdforce v1.x and removed in v2.0.0. Use `GetTests()` with the corresponding `athleteId`, `typeId`, `teamId`, or `groupId` argument instead.*
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
This is a basic example that shows a common workflow:
|
|
100
|
+
|
|
101
|
+
### Authenticate Session
|
|
102
|
+
``` Python
|
|
103
|
+
# Dependencies
|
|
104
|
+
import hdforce
|
|
105
|
+
# Run authentication manager
|
|
106
|
+
AuthManager(authMethod="env", region= "Americas")
|
|
107
|
+
```
|
|
108
|
+
### Get HD Data
|
|
109
|
+
#### Test Types
|
|
110
|
+
``` Python
|
|
111
|
+
# Test Types
|
|
112
|
+
types = hdforce.GetTypes()
|
|
113
|
+
|
|
114
|
+
types
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Organization Data
|
|
118
|
+
#### Get Athletes
|
|
119
|
+
``` Python
|
|
120
|
+
# Get Athletes
|
|
121
|
+
roster = hdforce.GetAthletes( includeInactive= False) # includeInactive defaults to False
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Athlete example
|
|
125
|
+
roster[roster['name'] =="Lauren Green"]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Get Tags
|
|
129
|
+
``` Python
|
|
130
|
+
# Get Tags
|
|
131
|
+
tags = hdforce.GetTags()
|
|
132
|
+
|
|
133
|
+
# Tags example
|
|
134
|
+
tags[0:6]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Get Tests
|
|
138
|
+
``` Python
|
|
139
|
+
# Get Tags
|
|
140
|
+
allTests = hdforce.GetTests()
|
|
141
|
+
# Filter my tests
|
|
142
|
+
mytests = allTests[allTests['athlete.name'] =="Lauren Green"]
|
|
143
|
+
# Slice some rows and columns
|
|
144
|
+
df = mytests.iloc[:5,:15]
|
|
145
|
+
|
|
146
|
+
df
|
|
147
147
|
```
|