Skip to content

Commit

Permalink
Create DATA_DIR after importing config (#4143)
Browse files Browse the repository at this point in the history
Delay creating DATA_DIR until config is fully imported.

This allows superset_config.py to override DATA_DIR before superset
attempts to create it in a potentially unwriteable location.
  • Loading branch information
leorochael authored and mistercrunch committed Jan 3, 2018
1 parent 3720509 commit ef06a9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 3 additions & 0 deletions superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
APP_DIR = os.path.dirname(__file__)
CONFIG_MODULE = os.environ.get('SUPERSET_CONFIG', 'superset.config')

if not os.path.exists(config.DATA_DIR):
os.makedirs(config.DATA_DIR)

with open(APP_DIR + '/static/assets/backendSync.json', 'r') as f:
frontend_config = json.load(f)

Expand Down
2 changes: 0 additions & 2 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
DATA_DIR = os.environ['SUPERSET_HOME']
else:
DATA_DIR = os.path.join(os.path.expanduser('~'), '.superset')
if not os.path.exists(DATA_DIR):
os.makedirs(DATA_DIR)

# ---------------------------------------------------------
# Superset specific config
Expand Down

1 comment on commit ef06a9d

@allanw
Copy link

@allanw allanw commented on ef06a9d May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code thread safe? I'm running Superset via Gunicon and specifying 3 threads. I've seen a FileExistsError in the logs - it seems that it might be trying to create the .superset file, but is failing to do so as the file already exists.

Please sign in to comment.