class_docstr: Log OpenAI fine-tunes to [Weights & Biases](https://wandb.me/openai-docs).
class_docstr_tok: ["Log","OpenAI","fine-tunes","to","[","Weights","&","Biases","]","(","https",":","\/\/wandb.me\/openai-docs",")","."]
code: def _log_artifact_inputs(
      cls,
      file_id: Optional[str],
      prefix: str,
      artifact_type: str,
      project: str,
      entity: Optional[str],
  ) -> None:
      # get input artifact
      artifact_name = f"{prefix}-{file_id}"
      # sanitize name to valid wandb artifact name
      artifact_name = re.sub(r"[^a-zA-Z0-9_\-.]", "_", artifact_name)
      artifact_alias = file_id
      artifact_path = f"{project}/{artifact_name}:{artifact_alias}"
      if entity is not None:
          artifact_path = f"{entity}/{artifact_path}"
      artifact = cls._get_wandb_artifact(artifact_path)
  
      # create artifact if file not already logged previously
      if artifact is None:
          # get file content
          try:
              file_content = cls.openai_client.files.retrieve_content(
                  file_id=file_id
              )
          except openai.NotFoundError:
              wandb.termerror(
                  f"File {file_id} could not be retrieved. Make sure you are allowed to download training/validation files"
              )
              return
  
          artifact = wandb.Artifact(artifact_name, type=artifact_type)
          with artifact.new_file(
              file_id, mode="w", encoding="utf-8"
          ) as f:
              f.write(file_content)
  
          # create a Table
          try:
              table, n_items = cls._make_table(file_content)
              # Add table to the artifact.
              artifact.add(table, file_id)
              # Add the same table to the workspace.
              cls._run.log({f"{prefix}_data": table})
              # Update the run config and artifact metadata
              cls._run.config.update({f"n_{prefix}": n_items})
              artifact.metadata["items"] = n_items
          except Exception:
              wandb.termerror(
                  f"File {file_id} could not be read as a valid JSON file"
              )
      else:
          # log number of items
          cls._run.config.update(
              {f"n_{prefix}": artifact.metadata.get("items")}
          )
  
      cls._run.use_artifact(
          artifact, aliases=["latest", artifact_alias]
      )
  
imports: import datetime
  import io
  import json
  import re
  import time
  from typing import Any, Dict, Optional, Tuple
  from pkg_resources import parse_version
  import wandb
  from wandb import util
  from wandb.data_types import Table
  from wandb.sdk.lib import telemetry
  from wandb.sdk.wandb_run import Run
  from openai import OpenAI
  from openai.types.fine_tuning import FineTuningJob
  from openai.types.fine_tuning.fine_tuning_job import Hyperparameters
label_desc: Use image node_id 10 for calling the WandbLogger obj's underlying member method code with example usage: obj._log_artifact_inputs(cls, file_id, prefix, artifact_type, project, entity) without return types