-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #337 from alan-turing-institute/develop
AIrsenal 0.4.0
- Loading branch information
Showing
35 changed files
with
1,828 additions
and
1,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
team_name,att,mid,defn,ovr | ||
Chelsea,85,85,82,84 | ||
Manchester United,86,83,81,83 | ||
Arsenal,86,82,80,83 | ||
Manchester City,84,85,81,83 | ||
Tottenham Hotspur,86,82,81,82 | ||
Liverpool,83,82,80,82 | ||
Everton,79,82,79,80 | ||
West Ham United,80,79,78,79 | ||
Leicester City,79,79,76,78 | ||
Southampton,78,78,77,78 | ||
Stoke City,78,77,77,77 | ||
Watford,77,76,76,77 | ||
Crystal Palace,81,76,75,76 | ||
West Bromwich Albion,80,75,76,76 | ||
Swansea City,75,77,75,76 | ||
Bournemouth,76,74,75,75 | ||
Burnley,74,75,75,75 | ||
Newcastle United,74,75,75,75 | ||
Brighton & Hove Albion,74,74,73,74 | ||
Huddersfield Town,73,73,72,73 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,68 @@ | ||
""" | ||
Database can be either an sqlite file or a postgress server | ||
""" | ||
|
||
import os | ||
from airsenal import TMPDIR | ||
|
||
# Default connection string points to a local sqlite file in | ||
# airsenal/data/data.db | ||
|
||
DB_CONNECTION_STRING = "sqlite:///{}/data.db".format(TMPDIR) | ||
config_path = os.path.join(os.path.dirname(__file__), "..", "data") | ||
AIrsenalDBFile_path = os.path.join(config_path, "AIrsenalDBFile") | ||
AIrsenalDBUri_path = os.path.join(config_path, "AIrsenalDBUri") | ||
AIrsenalDBUser_path = os.path.join(config_path, "AIrsenalDBUser") | ||
AIrsenalDBPassword_path = os.path.join(config_path, "AIrsenalDBPassword") | ||
|
||
# Check that we're not trying to set location for both sqlite and postgres | ||
if "AIrsenalDBFile" in os.environ.keys() and "AIrsenalDBUri" in os.environ.keys(): | ||
if ("AIrsenalDBFile" in os.environ.keys() or os.path.exists(AIrsenalDBFile_path)) and ( | ||
"AIrsenalDBUri" in os.environ.keys() or os.path.exists(AIrsenalDBUri_path) | ||
): | ||
raise RuntimeError("Please choose only ONE of AIrsenalDBFile and AIrsenalDBUri") | ||
|
||
# location of sqlite file overridden by an env var | ||
# sqlite database in a local file with path specified by: | ||
# - AIrsenalDBFile environment variable | ||
# - airsenal/data/AIrsenalDBFile file | ||
# - platform-dependent temporary directory (default) | ||
if "AIrsenalDBFile" in os.environ.keys(): | ||
DB_CONNECTION_STRING = "sqlite:///{}".format(os.environ["AIrsenalDBFile"]) | ||
AIrsenalDBFile = os.environ["AIrsenalDBFile"] | ||
elif os.path.exists(AIrsenalDBFile_path): | ||
AIrsenalDBFile = open(AIrsenalDBFile_path).read().strip() | ||
else: | ||
AIrsenalDBFile = os.path.join(TMPDIR, "data.db") | ||
|
||
DB_CONNECTION_STRING = "sqlite:///{}".format(AIrsenalDBFile) | ||
|
||
# postgres database specified by: AIrsenalDBUri, AIrsenalDBUser, AIrsenalDBPassword | ||
# defined either as: | ||
# - environment variables | ||
# - Files in airsenal/data/ | ||
if "AIrsenalDBUri" in os.environ.keys() or os.path.exists(AIrsenalDBUri_path): | ||
if "AIrsenalDBUser" in os.environ.keys(): | ||
AIrsenalDBUser = os.environ["AIrsenalDBUser"] | ||
elif os.path.exists(AIrsenalDBUser_path): | ||
AIrsenalDBUser = open(AIrsenalDBUser_path).read().strip() | ||
else: | ||
raise RuntimeError( | ||
"AIrsenalDBUser must be defined when using a postgres database" | ||
) | ||
|
||
if "AIrsenalDBUser" in os.environ.keys(): | ||
AIrsenalDBPassword = os.environ["AIrsenalDBPassword"] | ||
elif os.path.exists(AIrsenalDBPassword_path): | ||
AIrsenalDBPassword = open(AIrsenalDBPassword_path).read().strip() | ||
else: | ||
raise RuntimeError( | ||
"AIrsenalDBPassword must be defined when using a postgres database" | ||
) | ||
|
||
if "AIrsenalDBUri" in os.environ.keys(): | ||
AIrsenalDBUri = os.environ["AIrsenalDBUri"] | ||
elif os.path.exists(AIrsenalDBUri_path): | ||
AIrsenalDBUri = open(AIrsenalDBUri_path).read().strip() | ||
else: | ||
raise RuntimeError( | ||
"AIrsenalDBUri must be defined when using a postgres database" | ||
) | ||
|
||
# location of postgres server | ||
if "AIrsenalDBUri" in os.environ.keys(): | ||
DB_CONNECTION_STRING = "postgres://{}:{}@{}/airsenal".format( | ||
os.environ["AIrsenalDBUser"], | ||
os.environ["AIrsenalDBPassword"], | ||
os.environ["AIrsenalDBUri"], | ||
AIrsenalDBUser, | ||
AIrsenalDBPassword, | ||
AIrsenalDBUri, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.