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

Updated python notebooks and documentation for 2.5.0 #1404

Merged
merged 3 commits into from
Jul 17, 2024
Merged
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ <h1>Source code for bailo.core.client</h1><div class="highlight"><pre>
<a class="viewcode-back" href="../../../../bailo.core/#bailo.core.client.Client.get_models">[docs]</a>
<span class="k">def</span> <span class="nf">get_models</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">kind</span><span class="p">:</span> <span class="n">EntryKind</span> <span class="o">=</span> <span class="n">EntryKind</span><span class="o">.</span><span class="n">MODEL</span><span class="p">,</span>
<span class="n">task</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">libraries</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]</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">filters</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]</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">search</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Find and returns a list of models based on provided search terms.</span>

<span class="sd"> :param kind: Either a Model or a Datacard</span>
<span class="sd"> :param task: Model task (e.g. image classification), defaults to None</span>
<span class="sd"> :param libraries: Model library (e.g. TensorFlow), defaults to []</span>
<span class="sd"> :param filters: Custom filters, defaults to []</span>
<span class="sd"> :param libraries: Model library (e.g. TensorFlow), defaults to None</span>
<span class="sd"> :param filters: Custom filters, defaults to None</span>
<span class="sd"> :param search: String to be located in model cards, defaults to &quot;&quot;</span>
<span class="sd"> :return: JSON response object</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ <h1>Source code for bailo.core.enums</h1><div class="highlight"><pre>
<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>



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

<span class="n">MODEL</span> <span class="o">=</span> <span class="s2">&quot;minimal-general-v10&quot;</span>
<span class="n">DATACARD</span> <span class="o">=</span> <span class="s2">&quot;minimal-data-card-v10&quot;</span>
<span class="n">ACCESS_REQUEST</span> <span class="o">=</span> <span class="s2">&quot;minimal-access-request-general-v10&quot;</span></div>

</pre></div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ <h1>Source code for bailo.helper.access_request</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">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">from</span> <span class="nn">bailo.core.client</span> <span class="kn">import</span> <span class="n">Client</span>
<span class="kn">from</span> <span class="nn">bailo.core.enums</span> <span class="kn">import</span> <span class="n">MinimalSchema</span>

<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="AccessRequest">
Expand Down Expand Up @@ -145,6 +149,8 @@ <h1>Source code for bailo.helper.access_request</h1><div class="highlight"><pre>

<span class="n">schema_id</span> <span class="o">=</span> <span class="n">json_access_request</span><span class="p">[</span><span class="s2">&quot;schemaId&quot;</span><span class="p">]</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Access request %s for model %s successfully retrieved from server.&quot;</span><span class="p">,</span> <span class="n">access_request_id</span><span class="p">,</span> <span class="n">model_id</span><span class="p">)</span>

<span class="k">return</span> <span class="bp">cls</span><span class="p">(</span>
<span class="n">client</span><span class="p">,</span>
<span class="n">model_id</span><span class="p">,</span>
Expand All @@ -159,15 +165,17 @@ <h1>Source code for bailo.helper.access_request</h1><div class="highlight"><pre>
<div class="viewcode-block" id="AccessRequest.create">
<a class="viewcode-back" href="../../../../bailo.helper/#bailo.helper.access_request.AccessRequest.create">[docs]</a>
<span class="nd">@classmethod</span>
<span class="k">def</span> <span class="nf">create</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">client</span><span class="p">:</span> <span class="n">Client</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">schema_id</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">AccessRequest</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">create</span><span class="p">(</span>
<span class="bp">cls</span><span class="p">,</span> <span class="n">client</span><span class="p">:</span> <span class="n">Client</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">metadata</span><span class="p">:</span> <span class="n">Any</span><span class="p">,</span> <span class="n">schema_id</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">MinimalSchema</span><span class="o">.</span><span class="n">ACCESS_REQUEST</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">AccessRequest</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Make an access request for the model.</span>

<span class="sd"> Posts an access request to Bailo to be reviewed</span>

<span class="sd"> :param client: A client object used to interact with Bailo</span>
<span class="sd"> :param name: The name of the access request</span>
<span class="sd"> :param model_id: A unique model ID within Bailo</span>
<span class="sd"> :param schema_id: A unique schema ID</span>
<span class="sd"> :param schema_id: A unique schema ID, defaults to minimal-access-request-general-v10</span>
<span class="sd"> :return: JSON response object</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">access_request_json</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">post_access_request</span><span class="p">(</span><span class="n">model_id</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span> <span class="n">schema_id</span><span class="p">)[</span><span class="s2">&quot;accessRequest&quot;</span><span class="p">]</span>
Expand All @@ -177,6 +185,10 @@ <h1>Source code for bailo.helper.access_request</h1><div class="highlight"><pre>
<span class="n">metadata</span> <span class="o">=</span> <span class="n">access_request_json</span><span class="p">[</span><span class="s2">&quot;metadata&quot;</span><span class="p">]</span>
<span class="n">created_by</span> <span class="o">=</span> <span class="n">access_request_json</span><span class="p">[</span><span class="s2">&quot;createdBy&quot;</span><span class="p">]</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Access request successfully created on server with ID %s for model %s.&quot;</span><span class="p">,</span> <span class="n">access_request_id</span><span class="p">,</span> <span class="n">model_id</span>
<span class="p">)</span>

<span class="k">return</span> <span class="bp">cls</span><span class="p">(</span>
<span class="n">client</span><span class="p">,</span>
<span class="n">model_id</span><span class="p">,</span>
Expand All @@ -196,14 +208,19 @@ <h1>Source code for bailo.helper.access_request</h1><div class="highlight"><pre>
<span class="sd"> :return: A message confirming the removal of the access request.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">delete_access_request</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model_id</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">access_request_id</span><span class="p">)</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Access request %s successfully deleted on server.&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">access_request_id</span><span class="p">)</span>

<span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="AccessRequest.update">
<a class="viewcode-back" href="../../../../bailo.helper/#bailo.helper.access_request.AccessRequest.update">[docs]</a>
<span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Update the current state of the access request to Bailo.&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">patch_access_request</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model_id</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">access_request_id</span><span class="p">,</span> <span class="n">metadata</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">patch_access_request</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model_id</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">access_request_id</span><span class="p">,</span> <span class="n">metadata</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">)</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Access request %s successfully updated on server.&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">access_request_id</span><span class="p">)</span></div>


<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ <h1>Source code for bailo.helper.datacard</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">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">from</span> <span class="nn">bailo.core.client</span> <span class="kn">import</span> <span class="n">Client</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="kn">from</span> <span class="nn">bailo.core.exceptions</span> <span class="kn">import</span> <span class="n">BailoException</span>
<span class="kn">from</span> <span class="nn">bailo.helper.entry</span> <span class="kn">import</span> <span class="n">Entry</span>

<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="Datacard">
<a class="viewcode-back" href="../../../../bailo.helper/#bailo.helper.datacard.Datacard">[docs]</a>
Expand Down Expand Up @@ -150,9 +153,12 @@ <h1>Source code for bailo.helper.datacard</h1><div class="highlight"><pre>
<span class="n">res</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">post_model</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">EntryKind</span><span class="o">.</span><span class="n">DATACARD</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="n">description</span><span class="p">,</span> <span class="n">team_id</span><span class="o">=</span><span class="n">team_id</span><span class="p">,</span> <span class="n">visibility</span><span class="o">=</span><span class="n">visibility</span>
<span class="p">)</span>
<span class="n">datacard_id</span> <span class="o">=</span> <span class="n">res</span><span class="p">[</span><span class="s2">&quot;model&quot;</span><span class="p">][</span><span class="s2">&quot;id&quot;</span><span class="p">]</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Datacard successfully created on server with ID %s.&quot;</span><span class="p">,</span> <span class="n">datacard_id</span><span class="p">)</span>

<span class="n">datacard</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span>
<span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">,</span>
<span class="n">datacard_id</span><span class="o">=</span><span class="n">res</span><span class="p">[</span><span class="s2">&quot;model&quot;</span><span class="p">][</span><span class="s2">&quot;id&quot;</span><span class="p">],</span>
<span class="n">datacard_id</span><span class="o">=</span><span class="n">datacard_id</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
<span class="n">description</span><span class="o">=</span><span class="n">description</span><span class="p">,</span>
<span class="n">visibility</span><span class="o">=</span><span class="n">visibility</span><span class="p">,</span>
Expand All @@ -179,6 +185,8 @@ <h1>Source code for bailo.helper.datacard</h1><div class="highlight"><pre>
<span class="sa">f</span><span class="s2">&quot;ID </span><span class="si">{</span><span class="n">datacard_id</span><span class="si">}</span><span class="s2"> does not belong to a datacard. Did you mean to use Model.from_id()?&quot;</span>
<span class="p">)</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Datacard %s successfully retrieved from server.&quot;</span><span class="p">,</span> <span class="n">datacard_id</span><span class="p">)</span>

<span class="n">datacard</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span>
<span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">,</span>
<span class="n">datacard_id</span><span class="o">=</span><span class="n">datacard_id</span><span class="p">,</span>
Expand Down
Loading
Loading