Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAI-1253 Client Datacard Class #1272

Merged
merged 13 commits into from
May 21, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/access_requests_demo/">Managing Access Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/datacards_demo/">Managing Datacards</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/experiment_tracking_demo/">Experiment Tracking with Bailo &amp; MLFlow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/models_and_releases_demo_pytorch/">Managing Models &amp; Releases (ResNet-50 Example with PyTorch)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/schemas_demo/">Managing Schemas</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/access_requests_demo/">Managing Access Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/datacards_demo/">Managing Datacards</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/experiment_tracking_demo/">Experiment Tracking with Bailo &amp; MLFlow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/models_and_releases_demo_pytorch/">Managing Models &amp; Releases (ResNet-50 Example with PyTorch)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/schemas_demo/">Managing Schemas</a></li>
Expand Down Expand Up @@ -87,12 +88,11 @@
<h1>Source code for bailo.core.client</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>

<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">from</span> <span class="nn">io</span> <span class="kn">import</span> <span class="n">BytesIO</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>

<span class="kn">from</span> <span class="nn">bailo.core.agent</span> <span class="kn">import</span> <span class="n">Agent</span><span class="p">,</span> <span class="n">TokenAgent</span>
<span class="kn">from</span> <span class="nn">bailo.core.enums</span> <span class="kn">import</span> <span class="n">ModelVisibility</span><span class="p">,</span> <span class="n">SchemaKind</span>
<span class="kn">from</span> <span class="nn">bailo.core.enums</span> <span class="kn">import</span> <span class="n">EntryKind</span><span class="p">,</span> <span class="n">ModelVisibility</span><span class="p">,</span> <span class="n">SchemaKind</span>
<span class="kn">from</span> <span class="nn">bailo.core.utils</span> <span class="kn">import</span> <span class="n">filter_none</span>


Expand All @@ -114,13 +114,15 @@ <h1>Source code for bailo.core.client</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="nf">post_model</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">kind</span><span class="p">:</span> <span class="n">EntryKind</span><span class="p">,</span>
<span class="n">description</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">team_id</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">visibility</span><span class="p">:</span> <span class="n">ModelVisibility</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Create a model.</span>

<span class="sd"> :param name: Name of the model</span>
<span class="sd"> :param kind: Either a Model or a Datacard</span>
<span class="sd"> :param description: Description of the model</span>
<span class="sd"> :param visibility: Enum to define model visibility (e.g public or private)</span>
<span class="sd"> :return: JSON response object</span>
Expand All @@ -131,6 +133,7 @@ <h1>Source code for bailo.core.client</h1><div class="highlight"><pre>
<span class="n">filtered_json</span> <span class="o">=</span> <span class="n">filter_none</span><span class="p">(</span>
<span class="p">{</span>
<span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span>
<span class="s2">&quot;kind&quot;</span><span class="p">:</span> <span class="n">kind</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="n">description</span><span class="p">,</span>
<span class="s2">&quot;visibility&quot;</span><span class="p">:</span> <span class="n">visibility</span><span class="p">,</span>
<span class="s2">&quot;teamId&quot;</span><span class="p">:</span> <span class="n">team_id</span><span class="p">,</span>
Expand Down Expand Up @@ -199,18 +202,20 @@ <h1>Source code for bailo.core.client</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="p">,</span>
<span class="n">model_id</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">kind</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">description</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">visibility</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Update a specific model using its unique ID.</span>

<span class="sd"> :param model_id: Unique model ID</span>
<span class="sd"> :param name: Name of the model, defaults to None</span>
<span class="sd"> :param kind: Either a Model or a Datacard</span>
<span class="sd"> :param description: Description of the model, defaults to None</span>
<span class="sd"> :param visibility: Enum to define model visibility (e.g. public or private), defaults to None</span>
<span class="sd"> :return: JSON response object</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">filtered_json</span> <span class="o">=</span> <span class="n">filter_none</span><span class="p">({</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="n">description</span><span class="p">,</span> <span class="s2">&quot;visibility&quot;</span><span class="p">:</span> <span class="n">visibility</span><span class="p">})</span>
<span class="n">filtered_json</span> <span class="o">=</span> <span class="n">filter_none</span><span class="p">({</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> <span class="s2">&quot;kind&quot;</span><span class="p">:</span> <span class="n">kind</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="n">description</span><span class="p">,</span> <span class="s2">&quot;visibility&quot;</span><span class="p">:</span> <span class="n">visibility</span><span class="p">})</span>

<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">agent</span><span class="o">.</span><span class="n">patch</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">url</span><span class="si">}</span><span class="s2">/v2/model/</span><span class="si">{</span><span class="n">model_id</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">json</span><span class="o">=</span><span class="n">filtered_json</span><span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/access_requests_demo/">Managing Access Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/datacards_demo/">Managing Datacards</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/experiment_tracking_demo/">Experiment Tracking with Bailo &amp; MLFlow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/models_and_releases_demo_pytorch/">Managing Models &amp; Releases (ResNet-50 Example with PyTorch)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/schemas_demo/">Managing Schemas</a></li>
Expand Down Expand Up @@ -124,6 +125,16 @@ <h1>Source code for bailo.core.enums</h1><div class="highlight"><pre>
<span class="n">MODEL_TECHNICAL_REVIEWER</span> <span class="o">=</span> <span class="s2">&quot;mtr&quot;</span>
<span class="n">MODEL_SENIOR_RESPONSIBLE_OFFICER</span> <span class="o">=</span> <span class="s2">&quot;msro&quot;</span></div>



<div class="viewcode-block" id="EntryKind">
<a class="viewcode-back" href="../../../../bailo.core/#bailo.core.enums.EntryKind">[docs]</a>
<span class="k">class</span> <span class="nc">EntryKind</span><span class="p">(</span><span class="n">ValuedEnum</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The type of model.&quot;&quot;&quot;</span>

<span class="n">MODEL</span> <span class="o">=</span> <span class="s2">&quot;model&quot;</span>
<span class="n">DATACARD</span> <span class="o">=</span> <span class="s2">&quot;data-card&quot;</span></div>

</pre></div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/access_requests_demo/">Managing Access Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/datacards_demo/">Managing Datacards</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/experiment_tracking_demo/">Experiment Tracking with Bailo &amp; MLFlow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/models_and_releases_demo_pytorch/">Managing Models &amp; Releases (ResNet-50 Example with PyTorch)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/schemas_demo/">Managing Schemas</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/access_requests_demo/">Managing Access Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/datacards_demo/">Managing Datacards</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/experiment_tracking_demo/">Experiment Tracking with Bailo &amp; MLFlow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/models_and_releases_demo_pytorch/">Managing Models &amp; Releases (ResNet-50 Example with PyTorch)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../notebooks/schemas_demo/">Managing Schemas</a></li>
Expand Down
Loading
Loading