code: def test_job(engine: Engine):
      args = ["a", 4]
      kwargs = {"k0": 0, "k1": "xyz"}
      job_spec = {"a": 2, "b": [0, 1, 2], "c": {"x": 1, "y": "foo"}}
      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",
      }
  
      # test basic job creation
      with session_scope(engine) as session:
          xg = ExperimentGroup()
          c = ContainerSpec.get_or_create(
              session=session, spec=container_spec
          )
          e = Experiment.get_or_create(
              xgroup=xg,
              container_spec=c,
              args=args,
              kwargs=kwargs,
          )
  
          jspec = JobSpec.get_or_create(
              experiment=e,
              spec=job_spec,
              platform=Platform.TEST,
          )
  
          job = Job(
              spec=jspec,
              container="container0",
              details={"job_id": 123},
          )
          session.add(e)
  
      # test job persistence
      with session_scope(engine) as session:
          j = session.query(Job).all()
          assert len(j) == 1
          j = j[0]
          assert j.container == "container0"
          assert j.experiment.args == args
          assert j.experiment.kwargs == kwargs
          assert j.spec.spec == job_spec
          assert j.details["job_id"] == 123
  
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 5 for calling a global function with example usage: test_job(engine) without return types