mlmdquery

Crates.iomlmdquery
lib.rsmlmdquery
version0.2.0
sourcesrc
created_at2021-08-10 14:42:08.838017
updated_at2022-04-03 10:34:58.323536
descriptionA command-line tool to query the contents of an ml-metadata DB.
homepagehttps://github.com/sile/mlmdquery
repositoryhttps://github.com/sile/mlmdquery
max_upload_size
id434292
size126,639
Takeru Ohta (sile)

documentation

README

mlmdquery

mlmdquery Documentation Actions Status License: MIT

A command-line tool to query the contents of an ml-metadata DB.

Features:

  • It is possible to specify more flexible search queries than the original Python API
  • You can get the number of items that match your query without having to fetch all the data

Usage Examples

Note

The following examples use a SQLite database file (mlmd.db). The database contents were generated by the example code described in the official getting started guide.


Get the artifacts in the DB:

$ mlmdquery get artifacts --db sqlite://mlmd.db
[
  {
    "id": 2,
    "name": null,
    "type": "SavedModel",
    "uri": "path/to/model/file",
    "state": "UNKNOWN",
    "ctime": 1628605220.769,
    "mtime": 1628605220.904,
    "properties": {
      "name": "MNIST-v1",
      "version": 1
    },
    "custom_properties": {}
  },
  {
    "id": 1,
    "name": null,
    "type": "DataSet",
    "uri": "path/to/data",
    "state": "UNKNOWN",
    "ctime": 1628605220.108,
    "mtime": 1628605220.235,
    "properties": {
      "day": 1,
      "split": "train"
    },
    "custom_properties": {}
  }
]

Count the artifacts in the DB:

$ export MLMD_DB=sqlite://mlmd.db
$ mlmdquery count artifacts
2

Specify the maximum number of artifacts:

$ mlmdquery get artifacts --limit 1
[
  {
    "id": 2,
    "name": null,
    "type": "SavedModel",
    "uri": "path/to/model/file",
    "state": "UNKNOWN",
    "ctime": 1628605220.769,
    "mtime": 1628605220.904,
    "properties": {
      "name": "MNIST-v1",
      "version": 1
    },
    "custom_properties": {}
  }
]

Specify the URI of the target artifact:
```console
$ export MLMD_DB=sqlite://mlmd.db
$ mlmdquery get artifacts --uri path/to/data
[
  {
    "id": 1,
    "name": null,
    "type": "DataSet",
    "uri": "path/to/data",
    "state": "UNKNOWN",
    "ctime": 1628605220.108,
    "mtime": 1628605220.235,
    "properties": {
      "day": 1,
      "split": "train"
    },
    "custom_properties": {}
  }
]

Available options of $ mlmdquery get artifacts:

$ mlmdquery get artifacts -h
Gets artifacts

USAGE:
    mlmdquery get artifacts [FLAGS] [OPTIONS] --db <db>

FLAGS:
        --asc        If specified, the search results will be sorted in ascending order
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --context <context>            Context ID to which target artifacts belong
        --ctime-end <ctime-end>        End of creation time (UNIX timestamp seconds)
        --ctime-start <ctime-start>    Start of creation time (UNIX timestamp seconds)
        --db <db>                      Database URL [env: MLMD_DB]
        --id <ids>...                  Target artifact IDs
        --limit <limit>                Maximum number of artifacts in a search result [default: 100]
        --mtime-end <mtime-end>        End of update time (UNIX timestamp seconds)
        --mtime-start <mtime-start>    Start of update time (UNIX timestamp seconds)
        --name <name>                  Target artifact name
        --offset <offset>              Number of artifacts to be skipped from a search result [default: 0]
        --order-by <order-by>          Field to be used to sort a search result [default: id]  [possible values: id,
                                       name, ctime, mtime]
        --type <type-name>             Target artifact type
        --uri <uri>                    Target artifact URI

Available commands:

$ mlmdquery -h
mlmdquery 0.1.0

USAGE:
    mlmdquery <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    count    Counts artifacts/executions/contexts/events
    get      Gets artifacts/executions/contexts/events
    help     Prints this message or the help of the given subcommand(s)

$ mlmdquery get -h
mlmdquery-get 0.1.0
Gets artifacts/executions/contexts/events

USAGE:
    mlmdquery get <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    artifact-types     Gets artifact types
    artifacts          Gets artifacts
    context-types      Gets context types
    contexts           Gets contexts
    events             Gets events
    execution-types    Gets execution types
    executions         Gets executions
    help               Prints this message or the help of the given subcommand(s)

How to build a static binary?

Please use rust-musl-builder.

Commit count: 44

cargo fmt