Skip to content

Commit 70ae6b0

Browse files
authored
Merge pull request #189 from intuit/cache
In memory caching
2 parents 813e7e8 + 50e11a8 commit 70ae6b0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

labs/TrapheusAI/providers/github_provider.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ def connect(self, input: str):
2121
}
2222
return request_headers, request_params
2323

24-
def query(self, input: str):
25-
request_headers, request_params = self.connect(input)
24+
25+
@streamlit.cache_data(ttl=3600)
26+
def query(_self, input: str):
27+
request_headers, request_params = _self.connect(input)
2628
response = requests.get(constants.GITHUB_END_POINT + constants.GITHUB_SEARCH_PATH, params=request_params,
2729
headers=request_headers)
2830
response.raise_for_status()
2931
response_body = response.json()
3032
return response_body
3133

32-
def extract_data(self, input: str):
34+
@streamlit.cache_data(ttl=3600)
35+
def extract_data(_self, input: str):
3336
formatted_results = []
34-
data = self.query(input).get("items", [])
37+
data = _self.query(input).get("items", [])
3538
for item in data:
3639
repo = item["repository"]["full_name"]
3740
repo_path = item["path"]

0 commit comments

Comments
 (0)