Skip to content

Commit

Permalink
fix: adp concurreny
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Oct 21, 2024
1 parent 18a85d2 commit 28641a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint:
- [email protected]
- [email protected]
- git-diff-check
- [email protected].0
- [email protected].1
- [email protected]
- [email protected]
- [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
io_manager_key="io_manager_gcs_avro",
group_name="adp_workforce_now",
compute_kind="python",
op_tags={"dagster/concurrency_key": "adp_wfn_api"},
check_specs=[build_check_spec_avro_schema_valid(asset_key)],
partitions_def=DailyPartitionsDefinition(
start_date="01/01/2021",
Expand Down
9 changes: 9 additions & 0 deletions src/teamster/libraries/adp/workforce_now/api/resources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

from dagster import ConfigurableResource, DagsterLogManager, InitResourceContext, _check
from oauthlib.oauth2 import BackendApplicationClient
from pydantic import PrivateAttr
Expand Down Expand Up @@ -93,4 +95,11 @@ def get_records(self, endpoint, params: dict | None = None) -> list[dict]:

params.update({"$skip": params["$skip"] + page_size})

# https://developers.adp.com/learn/key-concepts/access-tokens
# Your application should limit access to under 300 times in a 60 second
# period, with no more than 50 concurrent requests in any time. ADP will
# throttle your requests when this limit is exceeded. Then, return a
# response of HTTP 429 for too many requests.
time.sleep(60 / 300)

return all_records

0 comments on commit 28641a0

Please sign in to comment.