mirror of
https://github.com/clearml/clearml-server
synced 2025-01-31 02:46:53 +00:00
Add support for http serving
This commit is contained in:
parent
636ad4431d
commit
06b64cd13f
@ -7,6 +7,9 @@ import json
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
|
||||
|
||||
@ -16,9 +19,16 @@ def apply_mappings_to_host(host: str):
|
||||
data = json.load(json_data)
|
||||
es_server = host
|
||||
url = f"{es_server}/_template/{f.stem}"
|
||||
requests.delete(url)
|
||||
r = requests.post(
|
||||
url, headers={"Content-Type": "application/json"}, data=json.dumps(data)
|
||||
|
||||
session = requests.Session()
|
||||
adapter = HTTPAdapter(max_retries=Retry(5, backoff_factor=0.5))
|
||||
session.mount('http://', adapter)
|
||||
|
||||
session.delete(url)
|
||||
r = session.post(
|
||||
url,
|
||||
headers={"Content-Type": "application/json"},
|
||||
data=json.dumps(data),
|
||||
)
|
||||
return {"mapping": f.stem, "result": r.text}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user