code: def test_workon():
      """Test scenario having a configured experiment already setup."""
      name = "voici_voila"
      config = {"name": name}
      config["algorithm"] = {"random": {"seed": 1}}
      config["max_trials"] = 50
      config["exp_max_broken"] = 5
      config["user_args"] = [
          os.path.abspath(
              os.path.join(os.path.dirname(__file__), "black_box.py")
          ),
          "-x~uniform(-50, 50, precision=None)",
      ]
  
      with OrionState() as cfg:
          cmd_config = experiment_builder.get_cmd_config(config)
  
          builder = experiment_builder.ExperimentBuilder(
              cfg.storage, debug=cmd_config.get("debug")
          )
  
          experiment = builder.build(**cmd_config)
  
          workon(
              experiment,
              n_workers=2,
              max_trials=10,
              max_broken=5,
              max_idle_time=20,
              heartbeat=20,
              user_script_config="config",
              interrupt_signal_code=120,
              ignore_code_changes=True,
              executor="joblib",
              executor_configuration={"backend": "threading"},
          )
  
          storage = cfg.storage
  
          exp = list(storage.fetch_experiments({"name": name}))
          assert len(exp) == 1
          exp = exp[0]
          assert "_id" in exp
          assert exp["name"] == name
          assert exp["max_trials"] == 50
          assert exp["max_broken"] == 5
          assert exp["algorithm"] == {"random": {"seed": 1}}
          assert "user" in exp["metadata"]
          assert "datetime" in exp["metadata"]
          assert "user_script" in exp["metadata"]
          assert exp["metadata"]["user_args"] == config["user_args"]
  
          trials = experiment.fetch_trials_by_status("completed")
          assert len(trials) <= 22
          trials = list(
              sorted(trials, key=lambda trial: trial.submit_time)
          )
          assert trials[-1].status == "completed"
          params = trials[-1].params
          assert len(params) == 1
          px = params["/x"]
          assert isinstance(px, float)
          assert (px - 34.56789) < 20
  
imports: import os
  import shutil
  import subprocess
  import sys
  import tempfile
  from collections import defaultdict
  from contextlib import contextmanager
  import numpy
  import pytest
  import yaml
  import orion.core.cli
  import orion.core.io.experiment_builder
  from orion.core.cli.hunt import workon
  from orion.testing import OrionState
label_desc: Use image node_id 10 for calling a global function with example usage: test_workon() without return types