Skip to content
Snippets Groups Projects
Commit d69f7a7c authored by lukaszszpak's avatar lukaszszpak
Browse files

feat: change default model to nc

parent 292885ab
Branches
4 merge requests!10Revert "test if load_default will download dump",!9Merge request,!8Revert "test if load_default will download dump",!7Revert "test if load_default will download dump"
Pipeline #15153 failed with stages
in 25 seconds
[DOWNLOAD]
default_model = https://minio.clarin-pl.eu/public/models/plwn_api_dumps/plwn_dump_new_07-12-2022.sqlite
default_model = https://nc.clarin.e-science.pl/index.php/s/3p3exndFdqpnRGM
......@@ -7,48 +7,16 @@ import requests
from six.moves.urllib.request import urlopen
from six.moves import configparser
config = configparser.ConfigParser()
config_path = os.path.join(os.path.dirname(
os.path.abspath(__file__)), "config.ini")
config.read(config_path)
def get_available_models():
"""Returns available models."""
root = ET.parse(urlopen("https://minio.clarin-pl.eu/public")).getroot()
available_models = []
for child in root.findall(
"{http://s3.amazonaws.com/doc/2006-03-01/}Contents"):
if "models/plwn_api_dumps/" in str(
child.find(
"{http://s3.amazonaws.com/doc/2006-03-01/}Key").text):
string = child.find(
"{http://s3.amazonaws.com/doc/2006-03-01/}Key").text
substring = r"models/plwn_api_dumps/"
available_models.append(re.sub(substring, r'', string))
return available_models
def download(name="default_model"):
"""After called it downloads a specified database model."""
models = get_available_models()
if name == "default_model":
url = config["DOWNLOAD"][name]
r = requests.get(url)
with open(name, "wb") as f:
f.write(r.content)
f.close()
return
if name in models:
url = config["DOWNLOAD"]["default_model"]
url = url.replace("plwn_dump_new_07-12-2022.sqlite", name)
r = requests.get(url)
with open(name, "wb") as f:
f.write(r.content)
f.close()
else:
print("Cannot download: ",
name,
"\n Possible download options: ",
models)
url = config["DOWNLOAD"]
r = requests.get(url)
with open(name, "wb") as f:
f.write(r.content)
f.close()
return
......@@ -9,7 +9,7 @@ ENVNAME_DIST_NODEFAULT = 'PLWN_API_DIST_NO_DEFAULT_STORAGE'
setup_args = dict(
name='plwn_api_uuid',
version='0.1',
version='0.11',
license='LGPL-3.0+',
description='Python API to access plWordNet lexicon',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment