code: def get_or_create(cls, filename, md5sum, session, basedir):
      instance = (
          session.query(cls)
          .filter_by(filename=filename, md5sum=md5sum)
          .first()
      )
      if instance:
          return instance
      full_path = os.path.join(basedir, filename)
      md5sum_ = get_digest(full_path)
      assert (
          md5sum_ == md5sum
      ), "found md5 mismatch for {}: {} != {}".format(
          filename, md5sum, md5sum_
      )
      with open(full_path, "r") as f:
          return cls(filename=filename, md5sum=md5sum, content=f.read())
  
imports: import hashlib
  import json
  import os
  import sqlalchemy
  from sqlalchemy.ext.declarative import declarative_base
  from sacred.dependencies import get_digest
  from sacred.serializer import restore
label_desc: Use image node_id 1 for calling the Source obj's underlying member method code with example usage: obj.get_or_create(cls, filename, md5sum, session, basedir) and returns: instance, cls