original_docstring:  Log model flavor to Shipped Brain - similar to mlflow.<flavour>.log_model
  
      :param model: path to serialized model
      :param flavor: a valid model flavor
      :param input_example: one or several instances of valid model input
      :param signature:  ModelSignature describes model input and output Schema. The model signature can be inferred from
      datasets with valid model input and valid model output
  
      :return: logged model mlflow.entities.Run instance
      
docstring: Log model flavor to Shipped Brain - similar to mlflow..log_model
docstring_tokens: Log model flavor to Shipped Brain - similar to mlflow .. log_model
code: def _log_flavor(flavor: str,
                  input_example: Optional[Union[pandas.core.frame.DataFrame, numpy.ndarray, dict, list]],
                  signature: mlflow.models.signature.ModelSignature,
                  **kwargs) -> mlflow.entities.Run:
      """ Log model flavor to Shipped Brain - similar to mlflow.<flavour>.log_model
  
      :param model: path to serialized model
      :param flavor: a valid model flavor
      :param input_example: one or several instances of valid model input
      :param signature:  ModelSignature describes model input and output Schema. The model signature can be inferred from
      datasets with valid model input and valid model output
  
      :return: logged model mlflow.entities.Run instance
      """
      #print(f"[DEBUG] flavor={flavor}")
      #print(f"[DEBUG] kwargs={kwargs}")
  
      log_model_function_name = "log_model"
  
      # Required args by Shipped Brain
      # artifact_path arg. is required by [log_model] method
      # TODO handle model name
  
      assert _is_valid_flavor(flavor), f"Failed to validate model flavor. Bad model flavor '{flavor}'."
      assert hasattr(mlflow, flavor), f"Failed to log model. Could not find flavor '{flavor}' in mlflow." 
  
      flavor_module = eval(f"mlflow.{flavor}" )
      assert callable(getattr(flavor_module, log_model_function_name)), \
          f"Failed to log model. Flavor '{flavor}' does not have {log_model_function_name} method."
  
      log_model_function = eval(f"mlflow.{flavor}.{log_model_function_name}")
  
      # Get log_model function required args
      log_function_required_args_set = set(_get_required_log_model_args(log_model_function))
      # remove kwargs
      log_function_required_args_set -= set(["kwargs"])
      
      user_kwargs_set = set(kwargs.keys())
      #print("[DEBUG] All required args", log_function_required_args_set)
      
      missing_args = log_function_required_args_set - user_kwargs_set
  
      #print("[DEBUG] MISSING ARGS:", missing_args)
      assert len(missing_args) == 0, f"Failed to log model. Missing arguments {missing_args}"
  
      # Log the model
      active_run = mlflow.active_run()
      if not active_run:
          active_run = mlflow.start_run()
          log_model_function(signature=signature, input_example=input_example, **kwargs)
          mlflow.end_run()
      else:
          log_model_function(signature=signature, input_example=input_example, **kwargs)
  
      return active_run
code_tokens: def _log_flavor ( flavor : str , input_example : Optional [ Union [ pandas . core . frame . DataFrame , numpy . ndarray , dict , list ] ] , signature : mlflow . models . signature . ModelSignature , ** kwargs ) -> mlflow . entities . Run : log_model_function_name = "log_model" assert _is_valid_flavor ( flavor ) , f"Failed to validate model flavor. Bad model flavor '{flavor}'." assert hasattr ( mlflow , flavor ) , f"Failed to log model. Could not find flavor '{flavor}' in mlflow." flavor_module = eval ( f"mlflow.{flavor}" ) assert callable ( getattr ( flavor_module , log_model_function_name ) ) , f"Failed to log model. Flavor '{flavor}' does not have {log_model_function_name} method." log_model_function = eval ( f"mlflow.{flavor}.{log_model_function_name}" ) log_function_required_args_set = set ( _get_required_log_model_args ( log_model_function ) ) log_function_required_args_set -= set ( [ "kwargs" ] ) user_kwargs_set = set ( kwargs . keys ( ) ) missing_args = log_function_required_args_set - user_kwargs_set assert len ( missing_args ) == 0 , f"Failed to log model. Missing arguments {missing_args}" active_run = mlflow . active_run ( ) if not active_run : active_run = mlflow . start_run ( ) log_model_function ( signature = signature , input_example = input_example , ** kwargs ) mlflow . end_run ( ) else : log_model_function ( signature = signature , input_example = input_example , ** kwargs ) return active_run
short_docstring: Log model flavor to Shipped Brain - similar to mlflow.<flavour>.log_model
short_docstring_tokens: Log model flavor to Shipped Brain - similar to mlflow . <flavour > . log_model
comment: """ Log model flavor to Shipped Brain - similar to mlflow.<flavour>.log_model
  
      :param model: path to serialized model
      :param flavor: a valid model flavor
      :param input_example: one or several instances of valid model input
      :param signature:  ModelSignature describes model input and output Schema. The model signature can be inferred from
      datasets with valid model input and valid model output
  
      :return: logged model mlflow.entities.Run instance
      """$SEP$#print(f"[DEBUG] flavor={flavor}")$SEP$#print(f"[DEBUG] kwargs={kwargs}")$SEP$# Required args by Shipped Brain$SEP$# artifact_path arg. is required by [log_model] method$SEP$# TODO handle model name$SEP$# Get log_model function required args$SEP$# remove kwargs$SEP$#print("[DEBUG] All required args", log_function_required_args_set)$SEP$#print("[DEBUG] MISSING ARGS:", missing_args)$SEP$# Log the model