Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Docs for extensions #179

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions content/docs/extensions/build/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Build extensions

Build extensions add new types of builders to use with `build`
[API](/doc/api-reference/build) and [CLI](/doc/command-reference/build) commands

Typicaly they will implement [Builder](/doc/user-guide/mlem-abcs#builder)
interface
102 changes: 102 additions & 0 deletions content/docs/extensions/build/pip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Python Package Builds Support

Contains two Builder implementations: `pip` to create a directory with Python
Package from model and `whl` to create a wheel file with Python Package

## Description

**TODO**

## Examples

### Creating Python package from model using API

```python
from mlem.api import build

build(builder="pip",
model="https://github.com/iterative/example-mlem-get-started/rf",
package_name="my_model_package",
target="./build"
)

# ! pip install ./build
import my_model_package

data = ...
my_model_package.predict(data)
```

### Creating Python wheel package from model using CLI

```cli
$ mlem build whl -m https://github.com/iterative/example-mlem-get-started/rf \
--package_name my_model_package --target ./build --version 1.0.0
$ pip install ./build/my_model_package-1.0.0-py3-none-any.whl
```

### Creating wheel builder declaration and using it with CLI

```cli
$ mlem declare builder whl whl_conf --package_name my_model_package \
--target ./build --author mike0sv --email [email protected] --version 1.0.0
$ mlem build --load whl_conf \
--model https://github.com/iterative/example-mlem-get-started/rf
$ pip install ./build/my_model_package-1.0.0-py3-none-any.whl
```

## Implementation reference

### `class PipBuilder`

**MlemABC parent type**: `builder`

**MlemABC type**: `pip`

Create a directory python package

**Fields**:

- `package_name: str` _(required)_ - Name of python package

- `target: str` _(required)_ - Path to save result

- `python_version: str` - Required python version

- `short_description: str = ""` - short_description

- `url: str = ""` - url

- `email: str = ""` - author's email

- `author: str = ""` - author's name

- `version: str = "0.0.0"` - package version

---

### `class WhlBuilder`

**MlemABC parent type**: `builder`

**MlemABC type**: `whl`

Create a wheel with python package

**Fields**:

- `package_name: str` _(required)_ - Name of python package

- `target: str` _(required)_ - Path to save result

- `python_version: str` - Required python version

- `short_description: str = ""` - short_description

- `url: str = ""` - url

- `email: str = ""` - author's email

- `author: str = ""` - author's name

- `version: str = "0.0.0"` - package version
11 changes: 11 additions & 0 deletions content/docs/extensions/data/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Data extensions

Data extensions add support for new types of data object that MLEM can covert
into MLEM data objects in [`save` API method](/doc/api-reference/save)

Typicaly they will implement [DataType](/doc/user-guide/mlem-abcs#datatype),
[DataReader](/doc/user-guide/mlem-abcs#datareader) and
[DataWriter](/doc/user-guide/mlem-abcs#datawriter) interfaces.

Some also implement [ImportHook](/doc/user-guide/mlem-abcs#importhook) to
support [importing](/doc/user-guide/importing) files of some format.
113 changes: 113 additions & 0 deletions content/docs/extensions/data/numpy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Numpy Data Types Support

DataType, Reader and Writer implementations for `np.ndarray` and `np.number`
primitives

## Description

**TODO**

## Requirements

```bash
pip install mlem[numpy]
# or
pip install numpy
```

## Examples

### Saving and loading numpy array

```python
import numpy as np

from mlem.api import save, load


data = np.zeros((100,))

save(data, "array")

data = load("array")
```

## Implementation reference

### `class NumpyArrayReader`

**MlemABC parent type**: `data_reader`

**MlemABC type**: `numpy`

DataReader implementation for numpy ndarray

**Fields**:

- `data_type: DataType` _(required)_ - Resulting data type

---

### `class NumpyNumberReader`

**MlemABC parent type**: `data_reader`

**MlemABC type**: `numpy_number`

Read np.number objects

**Fields**:

- `data_type: NumpyNumberType` _(required)_ - Resulting data type

---

### `class NumpyNdarrayType`

**MlemABC parent type**: `data_type`

**MlemABC type**: `ndarray`

DataType implementation for `np.ndarray`

**Fields**:

- `dtype: str` _(required)_ - Data type of elements

---

### `class NumpyNumberType`

**MlemABC parent type**: `data_type`

**MlemABC type**: `number`

numpy.number DataType

**Fields**:

- `dtype: str` _(required)_ - `numpy.number` type name as string

---

### `class NumpyArrayWriter`

**MlemABC parent type**: `data_writer`

**MlemABC type**: `numpy`

DataWriter implementation for numpy ndarray

**No fields**

---

### `class NumpyNumberWriter`

**MlemABC parent type**: `data_writer`

**MlemABC type**: `numpy_number`

Write np.number objects

**No fields**
119 changes: 119 additions & 0 deletions content/docs/extensions/data/pandas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Pandas Data Types Support

DataType, Reader and Writer implementations for `pd.DataFrame` and `pd.Series`
ImportHook implementation for files saved with pandas

## Description

**TODO**

## Requirements

```bash
pip install mlem[pandas]
# or
pip install pandas
```

## Examples

```python

```

## Implementation reference

### `class PandasReader`

**MlemABC parent type**: `data_reader`

**MlemABC type**: `pandas`

DataReader for pandas dataframes

**Fields**:

- `data_type: DataFrameType` _(required)_ - Resulting data type

- `format: str` _(required)_ - name of pandas-supported format

---

### `class PandasSeriesReader`

**MlemABC parent type**: `data_reader`

**MlemABC type**: `pandas_series`

DataReader for pandas series

**Fields**:

- `data_type: SeriesType` _(required)_ - Resulting data type

- `format: str` _(required)_ - name of pandas-supported format

---

### `class DataFrameType`

**MlemABC parent type**: `data_type`

**MlemABC type**: `dataframe`

:class:`.DataType` implementation for `pandas.DataFrame`

**No fields**

---

### `class SeriesType`

**MlemABC parent type**: `data_type`

**MlemABC type**: `series`

:class:`.DataType` implementation for `pandas.Series` objects which
stores them as built-in Python dicts

**No fields**

---

### `class PandasWriter`

**MlemABC parent type**: `data_writer`

**MlemABC type**: `pandas`

DataWriter for pandas dataframes

**Fields**:

- `format: str` _(required)_ - name of pandas-supported format

---

### `class PandasSeriesWriter`

**MlemABC parent type**: `data_writer`

**MlemABC type**: `pandas_series`

DataWriter for pandas series

**Fields**:

- `format: str` _(required)_ - name of pandas-supported format

---

### `class PandasImport`

**MlemABC parent type**: `import`

**MlemABC type**: `pandas`

Import files as pd.DataFrame

**No fields**
Loading