# Path: sacred/dependencies.py
# def get_digest(filename):
#     """Compute the MD5 hash for a given file."""
#     h = hashlib.md5()
#     with open(filename, "rb") as f:
#         data = f.read(1 * MB)
#         while data:
#             h.update(data)
#             data = f.read(1 * MB)
#         return h.hexdigest()
# 
# Path: sacred/serializer.py
# def restore(flat):
#     return json.decode(_json.dumps(flat), keys=True)


import hashlib
import json
import os
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sacred.dependencies import get_digest
from sacred.serializer import restore
    )

    host_id = sa.Column(sa.Integer, sa.ForeignKey("host.host_id"))
    host = sa.orm.relationship("Host", backref=sa.orm.backref("runs"))

    experiment_id = sa.Column(sa.Integer, sa.ForeignKey("experiment.experiment_id"))
    experiment = sa.orm.relationship("Experiment", backref=sa.orm.backref("runs"))

    # artifacts = backref
    resources = sa.orm.relationship(
        "Resource", secondary=run_resource_association, backref="runs"
    )

    result = sa.Column(sa.Float)

    def to_json(self):
        return {
            "_id": self.run_id,
            "command": self.command,
            "start_time": self.start_time,
            "heartbeat": self.heartbeat,
            "stop_time": self.stop_time,
            "queue_time": self.queue_time,
            "status": self.status,
            "result": self.result,
            "meta": {"comment": self.comment, "priority": self.priority},
            "resources": [r.to_json() for r in self.resources],
            "artifacts": [a.to_json() for a in self.artifacts],
            "host": self.host.to_json(),
            "experiment": self.experiment.to_json(),

# Path: sacred/dependencies.py
# def get_digest(filename):
#     """Compute the MD5 hash for a given file."""
#     h = hashlib.md5()
#     with open(filename, "rb") as f:
#         data = f.read(1 * MB)
#         while data:
#             h.update(data)
#             data = f.read(1 * MB)
#         return h.hexdigest()
# 
# Path: sacred/serializer.py
# def restore(flat):
#     return json.decode(_json.dumps(flat), keys=True)


# Path: sacred/observers/sql_bases.py
import hashlib
import json
import os
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sacred.dependencies import get_digest
from sacred.serializer import restore

    )

    host_id = sa.Column(sa.Integer, sa.ForeignKey("host.host_id"))
    host = sa.orm.relationship("Host", backref=sa.orm.backref("runs"))

    experiment_id = sa.Column(sa.Integer, sa.ForeignKey("experiment.experiment_id"))
    experiment = sa.orm.relationship("Experiment", backref=sa.orm.backref("runs"))

    # artifacts = backref
    resources = sa.orm.relationship(
        "Resource", secondary=run_resource_association, backref="runs"
    )

    result = sa.Column(sa.Float)

    def to_json(self):
        return {
            "_id": self.run_id,
            "command": self.command,
            "start_time": self.start_time,
            "heartbeat": self.heartbeat,
            "stop_time": self.stop_time,
            "queue_time": self.queue_time,
            "status": self.status,
            "result": self.result,
            "meta": {"comment": self.comment, "priority": self.priority},
            "resources": [r.to_json() for r in self.resources],
            "artifacts": [a.to_json() for a in self.artifacts],
            "host": self.host.to_json(),
            "experiment": self.experiment.to_json(),

            "config": restore(json.loads(self.config)),