Mongo-Observer ID Creation not Thread/Process Safe
See original GitHub issueI often start multiple python my_experiment.py -m my_database
in parallel (using subprocess.check_output
). Every now and then two or more processes get the same ID in the MongoDB.
This is the basic script (without parameter setting, etc):
from multiprocessing.pool import ThreadPool as Pool
import subprocess
def run_configuration(_):
subprocess.check_output('python build_model.py tmp ', shell=True)
with Pool(3) as pool:
pool.map(run_configuration, 5*[None])
and the output will be
INFO - run_title - Running command 'command'
INFO - run_title - Running command 'command'
INFO - run_title - Started run with ID "427"
INFO - run_title - Started run with ID "427"
INFO - run_title - Running command 'command'
INFO - run_title - Started run with ID "428"
and I only end up with 2 entries in the database.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Observing an Experiment — Sacred 0.8.3 documentation
The first observer determines the _id of the run, or it can be set by the command line option --id . At the...
Read more >MongoObserver fails to add metrics to run.info #739 - GitHub
I initially reported this issue with Omniboard where metrics were not showing up in the list of runs, but could be viewed just...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems to fix it. Thank you both!
I have submitted pull-request #254.