Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4c43dc8
Add implementation of directory saving
decodyng Jul 26, 2019
4d18ad3
basic tests for s3 observer
decodyng Jul 26, 2019
4524364
remove unused imports
decodyng Jul 26, 2019
12bb9cc
fix format string
decodyng Jul 27, 2019
f687d9d
Add boto3 to requirements for testing purposes
decodyng Jul 29, 2019
bb3ecf5
fix flake8 issues and add moto for test mocking
decodyng Jul 29, 2019
b688cb6
hopefully fix issue with google compute engine
decodyng Jul 29, 2019
5de6e42
give up and install google-compute-engine
decodyng Jul 29, 2019
0027662
add default location
decodyng Jul 29, 2019
d1d7bae
add decode utf to enforce python 3.5 compatibility
decodyng Jul 29, 2019
5b993c2
Clean up and add more tests
decodyng Jul 30, 2019
5b44c48
fix format string
decodyng Jul 30, 2019
25d26c9
flake8 fixes
decodyng Jul 30, 2019
0c20f66
remove recursive artifacts
decodyng Jul 30, 2019
883ced1
remove newline
decodyng Jul 30, 2019
a8c3f59
add more test coverage
decodyng Jul 30, 2019
777a7f5
change observer name, refactor list_s3_subdirs to have an explicit bu…
decodyng Aug 20, 2019
a929db8
add ability to pass in region, and error on Observer creation if regi…
decodyng Aug 20, 2019
9788e86
fix error handling
decodyng Aug 20, 2019
f4a0299
fix comment
decodyng Aug 20, 2019
c1f49b9
Merge branch 'master' into s3_observer
decodyng Aug 20, 2019
3dd47bf
fix flake8 issues
decodyng Aug 20, 2019
bc5d296
explicitly set region in tests
decodyng Aug 20, 2019
ab5fafb
start to write s3observer docs
decodyng Aug 20, 2019
c86fe0c
Merge branch 's3_observer' of github.com:HumanCompatibleAI/sacred int…
decodyng Aug 20, 2019
fedf694
add requirement in tox file
decodyng Aug 20, 2019
3889e33
black reformatting
decodyng Aug 20, 2019
ed58c96
pass in region for tests
decodyng Aug 20, 2019
d481d66
remove use of os.path.join to get around issues with windows paths
decodyng Aug 20, 2019
3c2315c
more black reformatting
decodyng Aug 20, 2019
f418e34
remove comma because of python 3.5 syntax error
decodyng Aug 20, 2019
553b195
fix black project toml, update s3_join method, fix tests to use s3_join
decodyng Aug 20, 2019
a6b3415
reformat for black modulo mongo comma issue
decodyng Aug 20, 2019
fb07ac2
fix s3_join calls to not pass in list
decodyng Aug 20, 2019
df571a4
changes to mongo
decodyng Aug 21, 2019
3d1c48f
fix py35 issues
decodyng Aug 21, 2019
f5b10a4
sync py35 error cases with master
decodyng Aug 21, 2019
bcd1904
add new lines at end of files
decodyng Aug 21, 2019
e63720d
sync offending black files with master
decodyng Aug 21, 2019
d83a290
remove final newline
decodyng Aug 21, 2019
558a79c
add end quotations to pyproject.toml
decodyng Aug 21, 2019
6f99985
remove Z from test name
decodyng Aug 21, 2019
365d2d1
fix string line breaks
decodyng Aug 21, 2019
548d7c1
remove create method and update docs accordingly
decodyng Aug 21, 2019
00d1f34
remove create method from s3 tests
decodyng Aug 21, 2019
22ce54f
clean up docs
decodyng Aug 21, 2019
3d52c2f
fix black issue in test_s3_observer, worried this will annoy flake8
decodyng Aug 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ wrapt==1.10.8
scikit-learn==0.20.3
pymongo==3.8.0
py-cpuinfo==4.0
boto3>=1.9.0
moto>=1.3.13
google-compute-engine>=2.8.0
pre-commit==1.18.0
39 changes: 38 additions & 1 deletion docs/observers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Observers have a ``priority`` attribute, and are run in order of descending
priority. The first observer determines the ``_id`` of the run.


At the moment there are four observers that are shipped with Sacred:
At the moment there are five observers that are shipped with Sacred:

* The main one is the :ref:`mongo_observer` which stores all information in a
`MongoDB <http://www.mongodb.org/>`_.
Expand All @@ -20,6 +20,9 @@ At the moment there are four observers that are shipped with Sacred:
to store run information in a JSON file.
* The :ref:`sql_observer` connects to any SQL database and will store the
relevant information there.
* The :ref:`s3_observer` stores run information in an AWS S3 bucket, within
a given prefix/directory


But if you want the run information stored some other way, it is easy to write
your own :ref:`custom_observer`.
Expand Down Expand Up @@ -591,6 +594,40 @@ Schema
.. image:: images/sql_schema.png


.. _s3_observer:

S3 Observer
============
The S3Observer stores run information in a designated prefix location within a S3 bucket, either by
using an existing bucket, or creating a new one. Using the S3Observer requires that boto3 be
installed, and also that an AWS config file is created with a user's Access Key and Secret Key.
An easy way to do this is by installing AWS command line tools (``pip install awscli``) and
running ``aws configure``.

Adding a S3Observer
--------------------

To create an S3Observer in Python:

.. code-block:: python

from sacred.observers import S3Observer
ex.observers.append(S3Observer(bucket='my-awesome-bucket',
basedir='/my-project/my-cool-experiment/'))

By default, an S3Observer will use the region that is set in your AWS config file, but if you'd
prefer to pass in a specific region, you can use the ``region`` parameter of create to do so.
If you try to create an S3Observer without this parameter, and with region not set in your config
file, it will error out at the point of the observer object being created.

Directory Structure
--------------------

S3Observers follow the same conventions as FileStorageObservers when it comes to directory
structure within a S3 bucket: within ``s3://<bucket>/basedir/`` numeric run directories will be
created in ascending order, and each run directory will contain the files specified within the
FileStorageObserver Directory Structure documentation above.


Slack Observer
==============
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mock>=2.0.0
munch>=2.0.4
pbr>=1.10.0
wrapt>=1.10.8
packaging>=18.0
packaging>=18.0
boto3>=1.9.0
2 changes: 2 additions & 0 deletions sacred/observers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from sacred.observers.tinydb_hashfs import TinyDbObserver, TinyDbReader
from sacred.observers.slack import SlackObserver
from sacred.observers.telegram_obs import TelegramObserver
from sacred.observers.s3_observer import S3Observer


__all__ = (
Expand All @@ -19,4 +20,5 @@
"TinyDbReader",
"SlackObserver",
"TelegramObserver",
"S3Observer",
)
Loading