File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 2
2
Manage configurations of the API.
3
3
"""
4
4
5
+ import os
5
6
from pathlib import Path
6
7
from string import Template
7
8
import subprocess
8
9
9
10
import yaml
10
11
11
12
13
+ # Check if we are developing from local, to disable parts of the code that are compute
14
+ # intensive (eg. disables calls to Github API)
15
+ # The variables 'FORWARDED_ALLOW_IPS' serves as proxy for this, as it is only defined
16
+ # when running from the Docker container
17
+ IS_DEV = False if os .getenv ('FORWARDED_ALLOW_IPS' ) else True
18
+
12
19
# Paths
13
20
main_path = Path (__file__ ).parent .absolute ()
14
21
paths = {
Original file line number Diff line number Diff line change 9
9
from fastapi import HTTPException
10
10
import requests
11
11
12
+ import ai4papi .conf as papiconf
13
+
12
14
13
15
# Persistent requests session for faster requests
14
16
session = requests .Session ()
@@ -191,6 +193,12 @@ def get_github_info(owner, repo):
191
193
"""
192
194
Retrieve information from a Github repo
193
195
"""
196
+ # Avoid running this function if were are doing local development, because
197
+ # repeatedly calling the Github API will otherwise get you blocked
198
+ if papiconf .IS_DEV :
199
+ print ('[info] Skipping Github API info fetching (development).' )
200
+ return {}
201
+
194
202
# Retrieve information from Github API
195
203
url = f"https://api.github.com/repos/{ owner } /{ repo } "
196
204
headers = {'Authorization' : f'token { github_token } ' } if github_token else {}
Original file line number Diff line number Diff line change 10
10
#TODO: move to proper testing package
11
11
#TODO: rename test script: modules --> test_modules
12
12
13
+ import ai4papi .conf as papiconf
14
+
15
+
16
+ # We want to test full functionality, without disabling any parts
17
+ papiconf .IS_DEV = False
18
+
19
+
13
20
import catalog .modules
14
21
import catalog .tools
15
22
import deployments .modules
You can’t perform that action at this time.
0 commit comments