class_docstr: Implementation of a fully configurable CLI tool for anomalib.
  
  The advantage of this tool is its flexibility to configure the pipeline
  from both the CLI and a configuration file (.yaml or .json). It is even
  possible to use both the CLI and a configuration file simultaneously.
  For more details, the reader could refer to PyTorch Lightning CLI documentation.
class_docstr_tok: ["Implementation","of","a","fully","configurable","CLI","tool","for","anomalib",".","The","advantage","of","this","tool","is","its","flexibility","to","configure","the","pipeline","from","both","the","CLI","and","a","configuration","file","(",".yaml","or",".json",")",".","It","is","even","possible","to","use","both","the","CLI","and","a","configuration","file","simultaneously",".","For","more","details",",","the","reader","could","refer","to","PyTorch","Lightning","CLI","documentation","."]
docstr: Sets the default root directory depending on the subcommand type. <train, fit, predict, tune.>.
docstr_tok: ["Sets","the","default","root","directory","depending","on","the","subcommand","type",".","<","train",",","fit",",","predict",",","tune.",">","."]
code: def __set_default_root_dir(self) -> None:
      """Sets the default root directory depending on the subcommand type. <train, fit, predict, tune.>."""
      # Get configs.
      subcommand = self.config["subcommand"]
      config = self.config[subcommand]
  
      # If `resume_from_checkpoint` is not specified, it means that the project has not been created before.
      # Therefore, we need to create the project directory first.
      if config.trainer.resume_from_checkpoint is None:
          root_dir = config.trainer.default_root_dir or "./results"
          model_name = config.model.class_path.split(".")[-1].lower()
          data_name = config.data.class_path.split(".")[-1].lower()
          category = (
              config.data.init_args.category
              if "category" in config.data.init_args
              else ""
          )
          time_stamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
          default_root_dir = os.path.join(
              root_dir, model_name, data_name, category, time_stamp
          )
  
      # Otherwise, the assumption is that the project directory has alrady been created.
      else:
          # By default, train subcommand saves the weights to
          #   ./results/<model>/<data>/time_stamp/weights/model.ckpt.
          # For this reason, we set the project directory to the parent directory
          #   that is two-level up.
          default_root_dir = str(
              Path(config.trainer.resume_from_checkpoint).parent.parent
          )
  
      if config.visualization.image_save_path == "":
          self.config[subcommand].visualization.image_save_path = (
              default_root_dir + "/images"
          )
      self.config[
          subcommand
      ].trainer.default_root_dir = default_root_dir
  
file_path: anomalib/src/anomalib/utils/cli/cli.py
imports: from __future__ import annotations
  import logging
  import os
  import warnings
  from datetime import datetime
  from importlib import import_module
  from pathlib import Path
  from omegaconf.omegaconf import OmegaConf
  from pytorch_lightning.cli import LightningArgumentParser, LightningCLI
  from anomalib.utils.callbacks import CdfNormalizationCallback, ImageVisualizerCallback, LoadModelCallback, MetricsConfigurationCallback, MinMaxNormalizationCallback, ModelCheckpoint, PostProcessingConfigurationCallback, TilerConfigurationCallback, TimerCallback, add_visualizer_callback
  from anomalib.utils.loggers import configure_logger
label_desc: Use image node_id 2 for calling the AnomalibCLI obj's underlying member method code with example usage: obj.__set_default_root_dir() without return types