Skip to content

Commit

Permalink
update: enlarge client body size of nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
JJJHANG committed Feb 19, 2024
1 parent a1e789d commit 52da5dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 2 additions & 0 deletions nginx/production/taibif.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ server {
charset utf-8;
server_name portal.taibif.tw;
server_tokens off;
client_max_body_size 100M;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
Expand All @@ -35,6 +36,7 @@ server {
charset utf-8;
server_name portal.taibif.tw;
server_tokens off;
client_max_body_size 100M;

ssl_certificate /etc/letsencrypt/live/portal.taibif.tw/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/portal.taibif.tw/privkey.pem;
Expand Down
27 changes: 17 additions & 10 deletions taxon_mapping/gbif_taxon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
from datetime import date

def update_namecode(row):
gbif_url = 'http://127.0.0.1:8080/v2/api.php?format=json&source=gbif_backbone_txn&best=yes&names=' + str(row['name'])
gbif_url = 'http://127.0.0.1:8081/api.php?format=json&source=gbif_backbone_txn&best=yes&names=' + str(row['name'])

# solr 呼叫 nomanmatch 查詢
gbif_response = requests.post(gbif_url, json={"test": "in"})
gbif_data = json.loads(gbif_response.content.decode('utf-8'))
# gbif_response = requests.post(gbif_url, json={"test": "in"})
# gbif_data = json.loads(gbif_response.content.decode('utf-8'))
gbif_response = requests.get(gbif_url)
gbif_data = gbif_response.json()

try:
if gbif_data['data'][0][0]['results'][0]['match_type'] == 'Full match':
Expand All @@ -22,9 +24,11 @@ def update_namecode(row):


def check_namecode(row):
taicol_url = 'http://127.0.0.1:8080/v2/api.php?format=json&source=taicol&best=yes&names=' + str(row['nM_name'])
taicol_response = requests.post(taicol_url, json={"test": "in"})
taicol_data = json.loads(taicol_response.content.decode('utf-8'))
taicol_url = 'http://127.0.0.1:8081/api.php?format=json&source=taicol&best=yes&names=' + str(row['nM_name'])
# taicol_response = requests.post(taicol_url, json={"test": "in"})
# taicol_data = json.loads(taicol_response.content.decode('utf-8'))
taicol_response = requests.get(taicol_url)
taicol_data = taicol_response.json()


# taicol_data 無資料會報錯後去查詢GBIF
Expand All @@ -33,9 +37,12 @@ def check_namecode(row):
row['taxon_backbone'] = 'TaiCOL'
except:

gbif_url = 'http://127.0.0.1:8080/v2/api.php?format=json&source=gbif_backbone_txn&best=yes&names='+str(row['nM_name'])
gbif_response = requests.post(gbif_url, json={"test": "in"})
gbif_data = json.loads(gbif_response.content.decode('utf-8'))
gbif_url = 'http://127.0.0.1:8080/api.php?format=json&source=gbif_backbone_txn&best=yes&names='+str(row['nM_name'])
# gbif_response = requests.post(gbif_url, json={"test": "in"})
# gbif_data = json.loads(gbif_response.content.decode('utf-8'))

gbif_response = requests.get(gbif_url)
gbif_data = gbif_response.json()

try:
if gbif_data['data'][0][0]['results'][0]['match_type'] == 'Full match':
Expand Down Expand Up @@ -122,7 +129,7 @@ def check_namecode(row):

tmp_nomenMatch_result = taxon_file.apply(update_namecode, axis=1)

# 合併specie 資訊
# 合併species 資訊
seperated_file = seperated_file.rename(columns={'taibif_scientificname':'name','taxon_backbone':'backbone','taxon_rank':'rank'})
seperated_file = seperated_file.drop(columns=['Unnamed: 0','nM_name','taibif_vernacular_name','kingdomzh','phylumzh','classzh','orderzh','familyzh','genuszh'])
# print('seperated_file == ',seperated_file)
Expand Down
10 changes: 5 additions & 5 deletions taxon_mapping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ def update_highertaxon_api(row):
return pd.Series(row)


# 前置準備 - 建立 Postgres 資料庫於本地端,目前設置port為 9432
# 前置準備 - 建立 Postgres 資料庫於本地端,目前設置port為 5432

# 1. 原本 TaiCOL 更新
# 2. 新 TaiCOL 加入

print("==== STEP 0 = Load Database Information ====")

engine = db.create_engine('postgresql://postgres:[email protected]:9432/taibif')
engine = db.create_engine('postgresql://postgres:[email protected]:5432/taibif')
connection = engine.connect()
df_taxon = pd.read_sql('SELECT * FROM data_taxon', connection)

# ---- update Taxon information
sql_delete_temp_taxon = "DELETE FROM temp_taxon"
with engine.begin() as conn:
conn.execute(sql_delete_temp_taxon)
# sql_delete_temp_taxon = "DELETE FROM temp_taxon"
# with engine.begin() as conn:
# conn.execute(sql_delete_temp_taxon)

df_taxon['mapping_error'] = ''
df_taicolid_notnull = df_taxon[df_taxon.taicol_taxon_id.notnull()]
Expand Down

0 comments on commit 52da5dd

Please sign in to comment.