Skip to content

Commit

Permalink
Merge pull request #189 from intuit/cache
Browse files Browse the repository at this point in the history
In memory caching
  • Loading branch information
stationeros authored Nov 5, 2023
2 parents 813e7e8 + 50e11a8 commit 70ae6b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions labs/TrapheusAI/providers/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ def connect(self, input: str):
}
return request_headers, request_params

def query(self, input: str):
request_headers, request_params = self.connect(input)

@streamlit.cache_data(ttl=3600)
def query(_self, input: str):
request_headers, request_params = _self.connect(input)
response = requests.get(constants.GITHUB_END_POINT + constants.GITHUB_SEARCH_PATH, params=request_params,
headers=request_headers)
response.raise_for_status()
response_body = response.json()
return response_body

def extract_data(self, input: str):
@streamlit.cache_data(ttl=3600)
def extract_data(_self, input: str):
formatted_results = []
data = self.query(input).get("items", [])
data = _self.query(input).get("items", [])
for item in data:
repo = item["repository"]["full_name"]
repo_path = item["path"]
Expand Down

0 comments on commit 70ae6b0

Please sign in to comment.