code: def test_experiment(engine: Engine):
      container_spec = {
          "nogpu": True,
          "cloud_key": "/path/to/key.json",
          "image_tag": None,
          "dir": ["/extra/path0", "/extra/path2"],
          "base_dir": "/home/foo",
          "module": "train.py",
      }
  
      with session_scope(engine) as session:
          xg = ExperimentGroup(name="foo-xgroup")
          c = ContainerSpec.get_or_create(
              session=session, spec=container_spec
          )
          j = Experiment.get_or_create(
              xgroup=xg,
              container_spec=c,
              args=["arg0", "3", "arg1"],
              kwargs={"k0": 1, "k1": "s"},
          )
          session.add(xg)
  
      # check basic persistence, then create duplicate experiment
      with session_scope(engine) as session:
          e = session.query(Experiment).all()
          assert len(e) == 1
          e = e[0]
          assert e.args == ["arg0", "3", "arg1"]
          assert e.kwargs == {"k0": 1, "k1": "s"}
          assert e.xgroup.name == "foo-xgroup"
          assert e.container_spec.spec == container_spec
  
          new_e = Experiment.get_or_create(
              xgroup=e.xgroup,
              container_spec=e.container_spec,
              args=["arg0", "3", "arg1"],
              kwargs={"k0": 1, "k1": "s"},
          )
          session.add(new_e)
  
      # test that get_or_create worked as desired
      with session_scope(engine) as session:
          e = session.query(Experiment).all()
          assert len(e) == 1
          e = e[0]
          assert e.container_spec.spec == container_spec
  
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 3 for calling a global function with example usage: test_experiment(engine) without return types