Repository: idsia/sacred
Issue: FileStorageObserver without creating any directory at print_config mode

I 'm using ``FileStorageObserver`` and I have a question now.

```python
import sacred
from sacred.observers.file_storage import FileStorageObserver
ex = sacred.Experiment('test')
@ex.config
def config():
    dir = 'dir'
    observer = FileStorageObserver.create(dir)
    ex.observers.append(observer)
    del observer

@ex.automain
def main():
    pass
```
I used this code with ``print_config`` command, like,

```bash
python run.py print_config
````

Then, I could find ``dir`` directory there.

In my feeling, the directory creation, or files, should occur only when doing main routine, 
so does sacred support it?

Changed files:
sacred/observers/file_storage.py, tests/test_observers/test_file_storage_observer.py

diff --git a/sacred/observers/file_storage.py b/sacred/observers/file_storage.py
index a491d6c..2eb1b29 100644
--- a/sacred/observers/file_storage.py
+++ b/sacred/observers/file_storage.py
@@ -25,8 +25,6 @@ class FileStorageObserver(RunObserver):
     @classmethod
     def create(cls, basedir, resource_dir=None, source_dir=None,
                template=None, priority=DEFAULT_FILE_STORAGE_PRIORITY):
-        if not os.path.exists(basedir):
-            os.makedirs(basedir)
         resource_dir = resource_dir or os.path.join(basedir, '_resources')
         source_dir = source_dir or os.path.join(basedir, '_sources')
         if template is not None:
@@ -54,6 +52,8 @@ class FileStorageObserver(RunObserver):
 
     def queued_event(self, ex_info, command, host_info, queue_time, config,
                      meta_info, _id):
+        if not os.path.exists(self.basedir):
+            os.makedirs(self.basedir)
         if _id is None:
             self.dir = tempfile.mkdtemp(prefix='run_', dir=self.basedir)
         else:
@@ -90,6 +90,8 @@ class FileStorageObserver(RunObserver):
 
     def started_event(self, ex_info, command, host_info, start_time, config,
                       meta_info, _id):
+        if not os.path.exists(self.basedir):
+            os.makedirs(self.basedir)
         if _id is None:
             for i in range(200):
                 dir_nrs = [int(d) for d in os.listdir(self.basedir)
diff --git a/tests/test_observers/test_file_storage_observer.py b/tests/test_observers/test_file_storage_observer.py
index 4930349..d9ad0a1 100644
--- a/tests/test_observers/test_file_storage_observer.py
+++ b/tests/test_observers/test_file_storage_observer.py
@@ -38,7 +38,8 @@ def sample_run():
 
 @pytest.fixture()
 def dir_obs(tmpdir):
-    return tmpdir, FileStorageObserver.create(tmpdir.strpath)
+    basedir = tmpdir.join('file_storage')
+    return basedir, FileStorageObserver.create(basedir.strpath)
 
 
 @pytest.fixture
@@ -62,6 +63,34 @@ def tmpfile():
     os.remove(f.name)
 
 
+def test_fs_observer_create_does_not_create_basedir(dir_obs):
+    basedir, obs = dir_obs
+    assert not basedir.exists()
+
+
+def test_fs_observer_queued_event_creates_rundir(dir_obs, sample_run):
+    basedir, obs = dir_obs
+    _id = obs.queued_event(
+        sample_run['ex_info'], sample_run['command'], sample_run['host_info'],
+        datetime.datetime.utcnow(), sample_run['config'],
+        sample_run['meta_info'], sample_run['_id'])
+
+    assert _id is not None
+    run_dir = basedir.join(str(_id))
+    assert run_dir.exists()
+    config = json.loads(run_dir.join('config.json').read())
+    assert config == sample_run['config']
+
+    run = json.loads(run_dir.join('run.json').read())
+    assert run == {
+        'experiment': sample_run['ex_info'],
+        'command': sample_run['command'],
+        'host': sample_run['host_info'],
+        'meta': sample_run['meta_info'],
+        'status': 'QUEUED'
+    }
+
+
 def test_fs_observer_started_event_creates_rundir(dir_obs, sample_run):
     basedir, obs = dir_obs
     sample_run['_id'] = None