code: def test_container_spec(engine: Engine):
      spec = {
          "nogpu": True,
          "cloud_key": "/path/to/key.json",
          "image_tag": None,
          "dir": ["/extra/path0", "/extra/path2"],
          "base_dir": "/home/foo",
          "module": "train.py",
      }
  
      def validate_spec(session) -> ContainerSpec:
          s = session.query(ContainerSpec).all()
          assert len(s) == 1
          s = s[0]
          assert s.spec == spec
          assert s.user == current_user()
          return s
  
      # basic creation
      with session_scope(engine) as session:
          s = ContainerSpec.get_or_create(session=session, spec=spec)
          session.add(s)
  
      # test persistence, then create experiment
      with session_scope(engine) as session:
          s = validate_spec(session)
          xg = ExperimentGroup()
          e = Experiment.get_or_create(xgroup=xg, container_spec=s)
  
      # test experiment parent-child relationship
      with session_scope(engine) as session:
          s = validate_spec(session)
          assert len(s.experiments) == 1
          assert s.experiments[0].container_spec.id == s.id
  
file_path: caliban/tests/caliban/history/test_history.py
imports: from datetime import datetime
  from sqlalchemy.engine.base import Engine
  import pytest
  from caliban.history.types import ContainerSpec, Experiment, ExperimentGroup, Job, JobSpec, Platform
  from caliban.history.util import get_mem_engine, session_scope
  from caliban.util import current_user
label_desc: Use image node_id 1 for calling a global function with example usage: test_container_spec(engine) and returns: s