Skip to content

Commit

Permalink
Fix mongo overwrite type (#762)
Browse files Browse the repository at this point in the history
* Fix type of overwrite in MongoObserver

* Use None instead of instance check
  • Loading branch information
agrinh authored Nov 9, 2020
1 parent 7dde5ff commit e62bb68
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sacred/observers/mongo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union
import mimetypes
import os.path
import pickle
Expand Down Expand Up @@ -82,7 +82,7 @@ def __init__(
db_name: str = "sacred",
collection: str = "runs",
collection_prefix: str = "",
overwrite: Optional[bool] = None,
overwrite: Optional[Union[int, str]] = None,
priority: int = DEFAULT_MONGO_PRIORITY,
client: Optional["pymongo.MongoClient"] = None,
failure_dir: Optional[PathType] = None,
Expand Down Expand Up @@ -183,7 +183,7 @@ def initialize(
self.runs = runs_collection
self.metrics = metrics_collection
self.fs = fs
if isinstance(overwrite, (int, str)):
if overwrite is not None:
overwrite = int(overwrite)
run = self.runs.find_one({"_id": overwrite})
if run is None:
Expand Down Expand Up @@ -620,7 +620,7 @@ def __init__(
url: Optional[str] = None,
db_name: str = "sacred",
collection: str = "runs",
overwrite: Optional[bool] = None,
overwrite: Optional[Union[int, str]] = None,
priority: int = DEFAULT_MONGO_PRIORITY,
client: Optional["pymongo.MongoClient"] = None,
**kwargs
Expand Down

0 comments on commit e62bb68

Please sign in to comment.