Skip to content

Commit

Permalink
deploy: 40f799b
Browse files Browse the repository at this point in the history
  • Loading branch information
github-merge-queue[bot] committed Jan 31, 2025
1 parent 3113c34 commit a4263e2
Show file tree
Hide file tree
Showing 4 changed files with 695 additions and 62 deletions.
18 changes: 9 additions & 9 deletions datasets.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ <h1 class="title">Module <code>geoengine.datasets</code></h1>


class DatasetName:
&#39;&#39;&#39;A wrapper for a dataset id&#39;&#39;&#39;
&#39;&#39;&#39;A wrapper for a dataset name&#39;&#39;&#39;

__dataset_name: str

Expand All @@ -295,7 +295,7 @@ <h1 class="title">Module <code>geoengine.datasets</code></h1>

@classmethod
def from_response(cls, response: geoengine_openapi_client.CreateDatasetHandler200Response) -&gt; DatasetName:
&#39;&#39;&#39;Parse a http response to an `DatasetId`&#39;&#39;&#39;
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return DatasetName(response.dataset_name)

def __str__(self) -&gt; str:
Expand All @@ -305,7 +305,7 @@ <h1 class="title">Module <code>geoengine.datasets</code></h1>
return str(self)

def __eq__(self, other) -&gt; bool:
&#39;&#39;&#39;Checks if two dataset ids are equal&#39;&#39;&#39;
&#39;&#39;&#39;Checks if two dataset names are equal&#39;&#39;&#39;
if not isinstance(other, self.__class__):
return False

Expand Down Expand Up @@ -1189,13 +1189,13 @@ <h3>Class variables</h3>
<span>(</span><span>dataset_name: str)</span>
</code></dt>
<dd>
<div class="desc"><p>A wrapper for a dataset id</p></div>
<div class="desc"><p>A wrapper for a dataset name</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class DatasetName:
&#39;&#39;&#39;A wrapper for a dataset id&#39;&#39;&#39;
&#39;&#39;&#39;A wrapper for a dataset name&#39;&#39;&#39;

__dataset_name: str

Expand All @@ -1204,7 +1204,7 @@ <h3>Class variables</h3>

@classmethod
def from_response(cls, response: geoengine_openapi_client.CreateDatasetHandler200Response) -&gt; DatasetName:
&#39;&#39;&#39;Parse a http response to an `DatasetId`&#39;&#39;&#39;
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return DatasetName(response.dataset_name)

def __str__(self) -&gt; str:
Expand All @@ -1214,7 +1214,7 @@ <h3>Class variables</h3>
return str(self)

def __eq__(self, other) -&gt; bool:
&#39;&#39;&#39;Checks if two dataset ids are equal&#39;&#39;&#39;
&#39;&#39;&#39;Checks if two dataset names are equal&#39;&#39;&#39;
if not isinstance(other, self.__class__):
return False

Expand All @@ -1231,14 +1231,14 @@ <h3>Static methods</h3>
<span>def <span class="ident">from_response</span></span>(<span>response: geoengine_openapi_client.CreateDatasetHandler200Response) ‑> <a title="geoengine.datasets.DatasetName" href="#geoengine.datasets.DatasetName">DatasetName</a></span>
</code></dt>
<dd>
<div class="desc"><p>Parse a http response to an <code>DatasetId</code></p></div>
<div class="desc"><p>Parse a http response to an <code><a title="geoengine.datasets.DatasetName" href="#geoengine.datasets.DatasetName">DatasetName</a></code></p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def from_response(cls, response: geoengine_openapi_client.CreateDatasetHandler200Response) -&gt; DatasetName:
&#39;&#39;&#39;Parse a http response to an `DatasetId`&#39;&#39;&#39;
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return DatasetName(response.dataset_name)</code></pre>
</details>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1 class="title">Package <code>geoengine</code></h1>
from .layers import Layer, LayerCollection, LayerListing, LayerCollectionListing, \
LayerId, LayerCollectionId, LayerProviderId, \
layer_collection, layer
from .ml import register_ml_model, MlModelConfig
from .ml import register_ml_model, MlModelConfig, MlModelName
from .permissions import add_permission, remove_permission, add_role, remove_role, assign_role, revoke_role, \
ADMIN_ROLE_ID, REGISTERED_USER_ROLE_ID, ANONYMOUS_USER_ROLE_ID, Permission, Resource, UserId, RoleId
from .tasks import Task, TaskId
Expand Down
135 changes: 128 additions & 7 deletions ml.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ <h1 class="title">Module <code>geoengine.ml</code></h1>
Util functions for machine learning
&#39;&#39;&#39;

from __future__ import annotations
from pathlib import Path
import tempfile
from dataclasses import dataclass
import geoengine_openapi_client.models
from onnx import TypeProto, TensorProto, ModelProto
from onnx.helper import tensor_dtype_to_string
from geoengine_openapi_client.models import MlModelMetadata, MlModel, RasterDataType
Expand All @@ -52,10 +54,42 @@ <h1 class="title">Module <code>geoengine.ml</code></h1>
description: str = &#34;My Ml Model Description&#34;


class MlModelName:
&#39;&#39;&#39;A wrapper for an MlModel name&#39;&#39;&#39;

__ml_model_name: str

def __init__(self, ml_model_name: str) -&gt; None:
self.__ml_model_name = ml_model_name

@classmethod
def from_response(cls, response: geoengine_openapi_client.models.MlModelNameResponse) -&gt; MlModelName:
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return MlModelName(response.ml_model_name)

def __str__(self) -&gt; str:
return self.__ml_model_name

def __repr__(self) -&gt; str:
return str(self)

def __eq__(self, other) -&gt; bool:
&#39;&#39;&#39;Checks if two dataset names are equal&#39;&#39;&#39;
if not isinstance(other, self.__class__):
return False

return self.__ml_model_name == other.__ml_model_name # pylint: disable=protected-access

def to_api_dict(self) -&gt; geoengine_openapi_client.models.MlModelNameResponse:
return geoengine_openapi_client.models.MlModelNameResponse(
ml_model_name=str(self.__ml_model_name)
)


def register_ml_model(onnx_model: ModelProto,
model_config: MlModelConfig,
upload_timeout: int = 3600,
register_timeout: int = 60):
register_timeout: int = 60) -&gt; MlModelName:
&#39;&#39;&#39;Uploads an onnx file and registers it as an ml model&#39;&#39;&#39;

validate_model_config(
Expand Down Expand Up @@ -84,7 +118,8 @@ <h1 class="title">Module <code>geoengine.ml</code></h1>

model = MlModel(name=model_config.name, upload=str(upload_id), metadata=model_config.metadata,
display_name=model_config.display_name, description=model_config.description)
ml_api.add_ml_model(model, _request_timeout=register_timeout)
res_name = ml_api.add_ml_model(model, _request_timeout=register_timeout)
return MlModelName.from_response(res_name)


def validate_model_config(onnx_model: ModelProto, *,
Expand Down Expand Up @@ -144,7 +179,7 @@ <h1 class="title">Module <code>geoengine.ml</code></h1>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="geoengine.ml.register_ml_model"><code class="name flex">
<span>def <span class="ident">register_ml_model</span></span>(<span>onnx_model: onnx.onnx_ml_pb2.ModelProto, model_config: <a title="geoengine.ml.MlModelConfig" href="#geoengine.ml.MlModelConfig">MlModelConfig</a>, upload_timeout: int = 3600, register_timeout: int = 60)</span>
<span>def <span class="ident">register_ml_model</span></span>(<span>onnx_model: ModelProto, model_config: <a title="geoengine.ml.MlModelConfig" href="#geoengine.ml.MlModelConfig">MlModelConfig</a>, upload_timeout: int = 3600, register_timeout: int = 60)> <a title="geoengine.ml.MlModelName" href="#geoengine.ml.MlModelName">MlModelName</a></span>
</code></dt>
<dd>
<div class="desc"><p>Uploads an onnx file and registers it as an ml model</p></div>
Expand All @@ -155,7 +190,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<pre><code class="python">def register_ml_model(onnx_model: ModelProto,
model_config: MlModelConfig,
upload_timeout: int = 3600,
register_timeout: int = 60):
register_timeout: int = 60) -&gt; MlModelName:
&#39;&#39;&#39;Uploads an onnx file and registers it as an ml model&#39;&#39;&#39;

validate_model_config(
Expand Down Expand Up @@ -184,11 +219,12 @@ <h2 class="section-title" id="header-functions">Functions</h2>

model = MlModel(name=model_config.name, upload=str(upload_id), metadata=model_config.metadata,
display_name=model_config.display_name, description=model_config.description)
ml_api.add_ml_model(model, _request_timeout=register_timeout)</code></pre>
res_name = ml_api.add_ml_model(model, _request_timeout=register_timeout)
return MlModelName.from_response(res_name)</code></pre>
</details>
</dd>
<dt id="geoengine.ml.validate_model_config"><code class="name flex">
<span>def <span class="ident">validate_model_config</span></span>(<span>onnx_model: onnx.onnx_ml_pb2.ModelProto, *, input_type: geoengine_openapi_client.models.raster_data_type.RasterDataType, output_type: geoengine_openapi_client.models.raster_data_type.RasterDataType, num_input_bands: int)</span>
<span>def <span class="ident">validate_model_config</span></span>(<span>onnx_model: ModelProto, *, input_type: RasterDataType, output_type: RasterDataType, num_input_bands: int)</span>
</code></dt>
<dd>
<div class="desc"><p>Validates the model config. Raises an exception if the model config is invalid</p></div>
Expand Down Expand Up @@ -238,7 +274,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="geoengine.ml.MlModelConfig"><code class="flex name class">
<span>class <span class="ident">MlModelConfig</span></span>
<span>(</span><span>name: str, metadata: geoengine_openapi_client.models.ml_model_metadata.MlModelMetadata, display_name: str = 'My Ml Model', description: str = 'My Ml Model Description')</span>
<span>(</span><span>name: str, metadata: MlModelMetadata, display_name: str = 'My Ml Model', description: str = 'My Ml Model Description')</span>
</code></dt>
<dd>
<div class="desc"><p>Configuration for an ml model</p></div>
Expand Down Expand Up @@ -274,6 +310,84 @@ <h3>Class variables</h3>
</dd>
</dl>
</dd>
<dt id="geoengine.ml.MlModelName"><code class="flex name class">
<span>class <span class="ident">MlModelName</span></span>
<span>(</span><span>ml_model_name: str)</span>
</code></dt>
<dd>
<div class="desc"><p>A wrapper for an MlModel name</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class MlModelName:
&#39;&#39;&#39;A wrapper for an MlModel name&#39;&#39;&#39;

__ml_model_name: str

def __init__(self, ml_model_name: str) -&gt; None:
self.__ml_model_name = ml_model_name

@classmethod
def from_response(cls, response: geoengine_openapi_client.models.MlModelNameResponse) -&gt; MlModelName:
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return MlModelName(response.ml_model_name)

def __str__(self) -&gt; str:
return self.__ml_model_name

def __repr__(self) -&gt; str:
return str(self)

def __eq__(self, other) -&gt; bool:
&#39;&#39;&#39;Checks if two dataset names are equal&#39;&#39;&#39;
if not isinstance(other, self.__class__):
return False

return self.__ml_model_name == other.__ml_model_name # pylint: disable=protected-access

def to_api_dict(self) -&gt; geoengine_openapi_client.models.MlModelNameResponse:
return geoengine_openapi_client.models.MlModelNameResponse(
ml_model_name=str(self.__ml_model_name)
)</code></pre>
</details>
<h3>Static methods</h3>
<dl>
<dt id="geoengine.ml.MlModelName.from_response"><code class="name flex">
<span>def <span class="ident">from_response</span></span>(<span>response: geoengine_openapi_client.models.MlModelNameResponse) ‑> <a title="geoengine.ml.MlModelName" href="#geoengine.ml.MlModelName">MlModelName</a></span>
</code></dt>
<dd>
<div class="desc"><p>Parse a http response to an <code>DatasetName</code></p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def from_response(cls, response: geoengine_openapi_client.models.MlModelNameResponse) -&gt; MlModelName:
&#39;&#39;&#39;Parse a http response to an `DatasetName`&#39;&#39;&#39;
return MlModelName(response.ml_model_name)</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="geoengine.ml.MlModelName.to_api_dict"><code class="name flex">
<span>def <span class="ident">to_api_dict</span></span>(<span>self) ‑> geoengine_openapi_client.models.ml_model_name_response.MlModelNameResponse</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_api_dict(self) -&gt; geoengine_openapi_client.models.MlModelNameResponse:
return geoengine_openapi_client.models.MlModelNameResponse(
ml_model_name=str(self.__ml_model_name)
)</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
Expand Down Expand Up @@ -305,6 +419,13 @@ <h4><code><a title="geoengine.ml.MlModelConfig" href="#geoengine.ml.MlModelConfi
<li><code><a title="geoengine.ml.MlModelConfig.name" href="#geoengine.ml.MlModelConfig.name">name</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="geoengine.ml.MlModelName" href="#geoengine.ml.MlModelName">MlModelName</a></code></h4>
<ul class="">
<li><code><a title="geoengine.ml.MlModelName.from_response" href="#geoengine.ml.MlModelName.from_response">from_response</a></code></li>
<li><code><a title="geoengine.ml.MlModelName.to_api_dict" href="#geoengine.ml.MlModelName.to_api_dict">to_api_dict</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit a4263e2

Please sign in to comment.