class_docstr: TrialContext is the system-provided API to a Trial class.
class_docstr_tok: ["TrialContext","is","the","system-provided","API","to","a","Trial","class","."]
docstr: Create a context object suitable for debugging outside of Determined.
  
  An example for a subclass of :class:`~determined.pytorch.deepspeed.DeepSpeedTrial`:
  
  .. code-block:: python
  
      config = { ... }
      context = det.pytorch.deepspeed.DeepSpeedTrialContext.from_config(config)
      my_trial = MyDeepSpeedTrial(context)
  
      train_ds = my_trial.build_training_data_loader()
      for epoch_idx in range(3):
          for batch_idx, batch in enumerate(train_ds):
              metrics = my_trial.train_batch(batch, epoch_idx, batch_idx)
              ...
  
  An example for a subclass of :class:`~determined.keras._tf_keras_trial.TFKerasTrial`:
  
  .. code-block:: python
  
      config = { ... }
      context = det.keras.TFKerasTrialContext.from_config(config)
      my_trial = tf_keras_one_var_model.OneVarTrial(context)
  
      model = my_trial.build_model()
      model.fit(my_trial.build_training_data_loader())
      eval_metrics = model.evaluate(my_trial.build_validation_data_loader())
  
  Arguments:
      config: An experiment config file, in dictionary form.
docstr_tok: ["Create","a","context","object","suitable","for","debugging","outside","of","Determined",".","An","example","for","a","subclass","of",":","class",":","`","~determined.pytorch.deepspeed.DeepSpeedTrial","`",":","..","code-block",":",":","python","config","=","{","...","}","context","=","det.pytorch.deepspeed.DeepSpeedTrialContext.from_config","(","config",")","my_trial","=","MyDeepSpeedTrial","(","context",")","train_ds","=","my_trial.build_training_data_loader","(",")","for","epoch_idx","in","range","(","3",")",":","for","batch_idx",",","batch","in","enumerate","(","train_ds",")",":","metrics","=","my_trial.train_batch","(","batch",",","epoch_idx",",","batch_idx",")","...","An","example","for","a","subclass","of",":","class",":","`","~determined.keras._tf_keras_trial.TFKerasTrial","`",":","..","code-block",":",":","python","config","=","{","...","}","context","=","det.keras.TFKerasTrialContext.from_config","(","config",")","my_trial","=","tf_keras_one_var_model.OneVarTrial","(","context",")","model","=","my_trial.build_model","(",")","model.fit","(","my_trial.build_training_data_loader","(",")",")","eval_metrics","=","model.evaluate","(","my_trial.build_validation_data_loader","(",")",")","Arguments",":","config",":","An","experiment","config","file",",","in","dictionary","form","."]
code: def from_config(cls, config: Dict[str, Any]) -> "TrialContext":
      """
      Create a context object suitable for debugging outside of Determined.
  
      An example for a subclass of :class:`~determined.pytorch.deepspeed.DeepSpeedTrial`:
  
      .. code-block:: python
  
          config = { ... }
          context = det.pytorch.deepspeed.DeepSpeedTrialContext.from_config(config)
          my_trial = MyDeepSpeedTrial(context)
  
          train_ds = my_trial.build_training_data_loader()
          for epoch_idx in range(3):
              for batch_idx, batch in enumerate(train_ds):
                  metrics = my_trial.train_batch(batch, epoch_idx, batch_idx)
                  ...
  
      An example for a subclass of :class:`~determined.keras._tf_keras_trial.TFKerasTrial`:
  
      .. code-block:: python
  
          config = { ... }
          context = det.keras.TFKerasTrialContext.from_config(config)
          my_trial = tf_keras_one_var_model.OneVarTrial(context)
  
          model = my_trial.build_model()
          model.fit(my_trial.build_training_data_loader())
          eval_metrics = model.evaluate(my_trial.build_validation_data_loader())
  
      Arguments:
          config: An experiment config file, in dictionary form.
      """
      core_context, env = det._make_local_execution_env(
          managed_training=False,
          test_mode=False,
          config=config,
          checkpoint_dir="/tmp",
          tensorboard_path=pathlib.Path("/tmp/tensorboard"),
          limit_gpus=1,
      )
      return cls(core_context, env)
  
file_path: determined/harness/determined/_trial_context.py
imports: import logging
  import pathlib
  from typing import Any, Dict
  import determined
  from determined import core
label_desc: Use image node_id 2 for calling the TrialContext obj's underlying member method code with example usage: obj.from_config(cls, config) and returns: cls