Class ModelCardCLI

java.lang.Object
org.tribuo.interop.modelcard.ModelCardCLI
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.command.CommandGroup

public class ModelCardCLI extends Object implements com.oracle.labs.mlrg.olcut.command.CommandGroup
A command line interface for creating and appending UsageDetails to the serialized version of an existing ModelCard.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    CLI options for ModelCardCLI.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addConsideration(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String consideration)
    Adds a consideration for the model documented by the ModelCard to its list of considerations.
    addFactor(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String factor)
    Adds a factor for the model documented by the ModelCard to its list of factors.
    addOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String use)
    Adds an out-of-scope use of the model documented by the ModelCard to its list of out-of-scope uses.
    addPreProcessingStep(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String step)
    Adds a pre-processing step for the model documented by the ModelCard to its list of pre-processing steps.
    addResource(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String resource)
    Adds a resource for the model documented by the ModelCard to its list of resources.
    clearUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Creates a new instance of UsageDetailsBuilder to allow a new UsageDetails to be written.
    close(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Closes the command shell
     
     
    intendedUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String use)
    Records the intended use of the model documented by the ModelCard.
    intendedUsers(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String users)
    Records the intended users of the model documented by the ModelCard.
    loadModel(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File path, boolean protobuf)
    Loads in a model and builds a partial model card from the provenance.
    loadModelCard(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File modelCardFile)
    Loads a model card in from disk.
    static void
    main(String[] args)
    Entry point.
    modelCitation(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String citation)
    Records the citation the model documented by the ModelCard.
    modelLicense(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String license)
    Records the license the model documented by the ModelCard.
    primaryContact(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String contact)
    Records the primary contact person of the model documented by the ModelCard.
    removeConsideration(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
    Removes a consideration of the model documented by the ModelCard from its list of considerations.
    removeFactor(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
    Removes a factor of the model documented by the ModelCard from its list of factors.
    removeOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
    Removes an out-of-scope use of the model documented by the ModelCard from its list of out-of-scope uses.
    removePreProcessingStep(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
    Removes a pre-processing step of the model documented by the ModelCard from its list of pre-processing steps.
    removeResource(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
    Removes a resource of the model documented by the ModelCard from its list of resources.
    saveUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File destinationFile)
    Saves a serialized version of the UsageDetails created by the builder to the destination file.
    void
    Starts the command shell.
    viewConsiderations(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints all recorded considerations of the model documented by the ModelCard.
    viewFactors(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints all recorded factors of the model documented by the ModelCard.
    viewModelCard(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints the current model card, incorporating the current usage details.
    viewModelProvenance(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints the current model provenance.
    viewOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints all recorded out-of-scope uses of the model documented by the ModelCard.
    viewPreProcessingSteps(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints all recorded pro-processing of the model documented by the ModelCard.
    viewResources(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints all recorded resources of the model documented by the ModelCard.
    viewUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
    Prints the fields recorded by the user for their UsageDetails object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModelCardCLI

      public ModelCardCLI()
  • Method Details

    • startShell

      public void startShell()
      Starts the command shell.
    • getName

      public String getName()
      Specified by:
      getName in interface com.oracle.labs.mlrg.olcut.command.CommandGroup
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface com.oracle.labs.mlrg.olcut.command.CommandGroup
    • loadModel

      @Command(usage="<path> <is-protobuf> - Loads a model in and builds a partial model card from the provenance.") public String loadModel(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File path, boolean protobuf)
      Loads in a model and builds a partial model card from the provenance.
      Parameters:
      ci - The command shell.
      path - The path to load.
      protobuf - Is the model a protobuf?
      Returns:
      A status string.
    • intendedUse

      @Command(usage="<String> Records intended use of model.") public String intendedUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String use)
      Records the intended use of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      use - The intended use of model.
      Returns:
      A status string.
    • intendedUsers

      @Command(usage="<String> Records intended users of model.") public String intendedUsers(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String users)
      Records the intended users of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      users - The intended users of model.
      Returns:
      A status string.
    • addOutOfScopeUse

      @Command(usage="<String> Adds an out-of-scope use to list of out-of-scope uses.") public String addOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String use)
      Adds an out-of-scope use of the model documented by the ModelCard to its list of out-of-scope uses.
      Parameters:
      ci - The command shell.
      use - The description of an out-of-scope use of the model.
      Returns:
      A status string.
    • removeOutOfScopeUse

      @Command(usage="<int> Remove out-of-scope use at specified index (0-indexed).") public String removeOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
      Removes an out-of-scope use of the model documented by the ModelCard from its list of out-of-scope uses.
      Parameters:
      ci - The command shell.
      index - The index of the out-of-scope use to be removed.
      Returns:
      A status string.
    • viewOutOfScopeUse

      @Command(usage="Displays all added out-of-scope uses.") public String viewOutOfScopeUse(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints all recorded out-of-scope uses of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • addPreProcessingStep

      @Command(usage="<String> Adds pre-processing step to list of steps.") public String addPreProcessingStep(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String step)
      Adds a pre-processing step for the model documented by the ModelCard to its list of pre-processing steps.
      Parameters:
      ci - The command shell.
      step - The description of a pre-processing step.
      Returns:
      A status string.
    • removePreProcessingStep

      @Command(usage="<int> Remove pro-processing step at specified index (0-indexed).") public String removePreProcessingStep(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
      Removes a pre-processing step of the model documented by the ModelCard from its list of pre-processing steps.
      Parameters:
      ci - The command shell.
      index - The index of the pre-processing step to be removed.
      Returns:
      A status string.
    • viewPreProcessingSteps

      @Command(usage="Displays all added pre-processing steps.") public String viewPreProcessingSteps(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints all recorded pro-processing of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • addConsideration

      @Command(usage="<String> Adds consideration to list of considerations.") public String addConsideration(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String consideration)
      Adds a consideration for the model documented by the ModelCard to its list of considerations.
      Parameters:
      ci - The command shell.
      consideration - The description of a consideration.
      Returns:
      A status string.
    • removeConsideration

      @Command(usage="<int> Remove consideration at specified index (0-indexed).") public String removeConsideration(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
      Removes a consideration of the model documented by the ModelCard from its list of considerations.
      Parameters:
      ci - The command shell.
      index - The index of the consideration to be removed.
      Returns:
      A status string.
    • viewConsiderations

      @Command(usage="Displays all added considerations.") public String viewConsiderations(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints all recorded considerations of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • addFactor

      @Command(usage="<String> Adds relevant factor to list of factors.") public String addFactor(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String factor)
      Adds a factor for the model documented by the ModelCard to its list of factors.
      Parameters:
      ci - The command shell.
      factor - The description of a factor.
      Returns:
      A status string.
    • removeFactor

      @Command(usage="<int> Remove factor at specified index (0-indexed).") public String removeFactor(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
      Removes a factor of the model documented by the ModelCard from its list of factors.
      Parameters:
      ci - The command shell.
      index - The index of the factor to be removed.
      Returns:
      A status string.
    • viewFactors

      @Command(usage="Displays all added factors.") public String viewFactors(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints all recorded factors of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • addResource

      @Command(usage="<String> Adds resource to list of resources.") public String addResource(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String resource)
      Adds a resource for the model documented by the ModelCard to its list of resources.
      Parameters:
      ci - The command shell.
      resource - The description of a resource.
      Returns:
      A status string.
    • removeResource

      @Command(usage="<int> Remove resource at specified index (0-indexed).") public String removeResource(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int index)
      Removes a resource of the model documented by the ModelCard from its list of resources.
      Parameters:
      ci - The command shell.
      index - The index of the resource to be removed.
      Returns:
      A status string.
    • viewResources

      @Command(usage="Displays all added resources.") public String viewResources(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints all recorded resources of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • primaryContact

      @Command(usage="<String> Records primary contact in case of questions or comments.") public String primaryContact(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String contact)
      Records the primary contact person of the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      contact - The primary contact person of the model.
      Returns:
      A status string.
    • modelCitation

      @Command(usage="<String> Records model\'s citation.") public String modelCitation(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String citation)
      Records the citation the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      citation - The citation the model.
      Returns:
      A status string.
    • modelLicense

      @Command(usage="<String> Records model\'s license.") public String modelLicense(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String license)
      Records the license the model documented by the ModelCard.
      Parameters:
      ci - The command shell.
      license - The license the model.
      Returns:
      A status string.
    • loadModelCard

      @Command(usage="<filename> - Loads in an existing model card without usage details") public String loadModelCard(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File modelCardFile) throws IOException
      Loads a model card in from disk. Fails if the model card already includes the usage information.
      Parameters:
      ci - The command interpreter.
      modelCardFile - The model card file to load.
      Returns:
      A status string.
      Throws:
      IOException - If the card failed to load.
    • saveUsageDetails

      @Command(usage="<filename> Saves UsageDetails to an existing ModelCard file.") public String saveUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File destinationFile) throws IOException
      Saves a serialized version of the UsageDetails created by the builder to the destination file.

      Throws IllegalArgumentException if the serialized ModelCard stored at the destination file already contains a non-null UsageDetails.

      Parameters:
      ci - The command shelll.
      destinationFile - The file path where the model card will be saved in json format.
      Returns:
      A status string.
      Throws:
      IOException - if a problem is encountered when writing to the file.
    • clearUsageDetails

      @Command(usage="Removes all previously written fields for UsageDetails and clears the model to write a new UsageDetails.") public String clearUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Creates a new instance of UsageDetailsBuilder to allow a new UsageDetails to be written.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • viewUsageDetails

      @Command(usage="Displays current state of UsageDetails.") public String viewUsageDetails(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints the fields recorded by the user for their UsageDetails object.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • viewModelCard

      @Command(usage="Displays the current model card.") public String viewModelCard(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints the current model card, incorporating the current usage details.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • viewModelProvenance

      @Command(usage="Displays the currently loaded model, if there is one.") public String viewModelProvenance(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Prints the current model provenance.
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • close

      @Command(usage="Closes CLI without explicitly saving anything recorded.") public String close(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci)
      Closes the command shell
      Parameters:
      ci - The command shell.
      Returns:
      A status string.
    • main

      public static void main(String[] args)
      Entry point.
      Parameters:
      args - CLI args.