diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-02-07 10:59:51 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-02-07 10:59:51 +0100 |
commit | c76f1d9dbb77746012c688a8d60ed45559ad0a4a (patch) | |
tree | a10d3f9dd8c32444229edce924d37653cd84ff13 /scripts | |
parent | 704a729f5cbcf5b319fe9ce6e0436554d8b5d9b0 (diff) |
Made the tuning database an optional external download
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/database/database.db | bin | 2094065 -> 0 bytes | |||
-rw-r--r-- | scripts/database/database.py | 24 |
2 files changed, 22 insertions, 2 deletions
diff --git a/scripts/database/database.db b/scripts/database/database.db Binary files differdeleted file mode 100644 index bf793177..00000000 --- a/scripts/database/database.db +++ /dev/null diff --git a/scripts/database/database.py b/scripts/database/database.py index 66169121..758fdbab 100644 --- a/scripts/database/database.py +++ b/scripts/database/database.py @@ -15,10 +15,17 @@ import os.path import glob import re import json +try: + from urllib.request import urlopen # Python 3 +except ImportError: + from urllib2 import urlopen # Python 2 # Additional modules import pandas as pd +# Server storing a copy of the database +DATABASE_SERVER_URL = "http://www.cedricnugteren.nl/tuning/clblast.db" + # Constants VENDOR_DEFAULT = "default" DEVICETYPE_DEFAULT = "All" @@ -38,6 +45,15 @@ pd.set_option('display.width', 1000) # Database operations # ================================================================================================== +# Downloads the database and save it to disk +def DownloadDatabase(filename): + sys.stdout.write("## Downloading database from '"+DATABASE_SERVER_URL+"'...") + df = urlopen(DATABASE_SERVER_URL) + output = open(file_db,'wb') + output.write(df.read()) + output.close() + print("done") + # Loads the database from disk def LoadDatabase(filename): return pd.read_pickle(filename) @@ -221,9 +237,13 @@ if len(glob.glob(glob_json)) < 1: # The main body of the script # ================================================================================================== -# Loads the database if it exists. If not, a new database is initialized +# Downloads the database if a local copy is not present db_exists = os.path.isfile(file_db) -database = LoadDatabase(file_db) if db_exists else pd.DataFrame() +if not db_exists: + DownloadDatabase(file_db) + +# Loads the database from disk +database = LoadDatabase(file_db) # Loops over all JSON files in the supplied folder for file_json in glob.glob(glob_json): |