Skip to content

Commit

Permalink
deploy: bacdb0e
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipMay committed Dec 31, 2023
1 parent d4a9231 commit 98980cc
Show file tree
Hide file tree
Showing 24 changed files with 1,009 additions and 15 deletions.
4 changes: 3 additions & 1 deletion _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
<div itemprop="articleBody">

<h1>All modules for which code is available</h1>
<ul><li><a href="mltb2/data.html">mltb2.data</a></li>
<ul><li><a href="mltb2/arangodb.html">mltb2.arangodb</a></li>
<li><a href="mltb2/data.html">mltb2.data</a></li>
<li><a href="mltb2/db.html">mltb2.db</a></li>
<li><a href="mltb2/fasttext.html">mltb2.fasttext</a></li>
<li><a href="mltb2/files.html">mltb2.files</a></li>
<li><a href="mltb2/md.html">mltb2.md</a></li>
Expand Down
264 changes: 264 additions & 0 deletions _modules/mltb2/arangodb.html

Large diffs are not rendered by default.

162 changes: 162 additions & 0 deletions _modules/mltb2/db.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>mltb2.db &mdash; MLTB2 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/css/custom.css?v=de248184" />


<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js?v=b3ba4146"></script>
<script src="../../_static/doctools.js?v=888ff710"></script>
<script src="../../_static/sphinx_highlight.js?v=4825356b"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../../_static/copybutton.js?v=f281be69"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../index.html" class="icon icon-home">
MLTB2
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api-reference.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../genindex.html">Index</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/telekom/mltb2">GitHub Repository</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/telekom/mltb2/blob/main/LICENSE">License</a></li>
<li class="toctree-l1"><a class="reference external" href="https://www.telekom.com/imprint">Imprint</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">MLTB2</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">mltb2.db</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for mltb2.db</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) 2023 Philip May</span>
<span class="c1"># This software is distributed under the terms of the MIT license</span>
<span class="c1"># which is available at https://opensource.org/licenses/MIT</span>

<span class="sd">&quot;&quot;&quot;Database utils module.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">ABC</span><span class="p">,</span> <span class="n">abstractmethod</span>
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Sequence</span>


<div class="viewcode-block" id="AbstractBatchDataManager"><a class="viewcode-back" href="../../api-reference/db.html#mltb2.db.AbstractBatchDataManager">[docs]</a><span class="k">class</span> <span class="nc">AbstractBatchDataManager</span><span class="p">(</span><span class="n">ABC</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Abstract base class for batch processing of database data.</span>

<span class="sd"> This class (respectively an implementation of it) is intended to be</span>
<span class="sd"> used in conjunction with the :class:`BatchDataProcessor`.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<div class="viewcode-block" id="AbstractBatchDataManager.load_batch"><a class="viewcode-back" href="../../api-reference/db.html#mltb2.db.AbstractBatchDataManager.load_batch">[docs]</a> <span class="nd">@abstractmethod</span>
<span class="k">def</span> <span class="nf">load_batch</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Load a batch of data from the database.&quot;&quot;&quot;</span>
<span class="k">pass</span></div>

<div class="viewcode-block" id="AbstractBatchDataManager.save_batch"><a class="viewcode-back" href="../../api-reference/db.html#mltb2.db.AbstractBatchDataManager.save_batch">[docs]</a> <span class="nd">@abstractmethod</span>
<span class="k">def</span> <span class="nf">save_batch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">batch</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Save a batch of data to the database.&quot;&quot;&quot;</span>
<span class="k">pass</span></div></div>


<div class="viewcode-block" id="BatchDataProcessor"><a class="viewcode-back" href="../../api-reference/db.html#mltb2.db.BatchDataProcessor">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">BatchDataProcessor</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Process batches of data from a database.</span>

<span class="sd"> Args:</span>
<span class="sd"> data_manager: The data manager to load and save batches of data.</span>
<span class="sd"> process_batch_callback: A callback function that processes one batch of data.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">data_manager</span><span class="p">:</span> <span class="n">AbstractBatchDataManager</span>
<span class="n">process_batch_callback</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[[</span><span class="n">Sequence</span><span class="p">],</span> <span class="n">Sequence</span><span class="p">]</span>

<div class="viewcode-block" id="BatchDataProcessor.run"><a class="viewcode-back" href="../../api-reference/db.html#mltb2.db.BatchDataProcessor.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Run the batch data processing.</span>

<span class="sd"> This is done until the data manager returns an empty batch.</span>
<span class="sd"> For each batch the ``process_batch_callback`` is called.</span>
<span class="sd"> Data is loaded by using an implementation of the :class:`AbstractBatchDataManager`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
<span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_manager</span><span class="o">.</span><span class="n">load_batch</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">batch</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">break</span>
<span class="n">new_batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">process_batch_callback</span><span class="p">(</span><span class="n">batch</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">new_batch</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">data_manager</span><span class="o">.</span><span class="n">save_batch</span><span class="p">(</span><span class="n">new_batch</span><span class="p">)</span></div></div>
</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2023, Philip May, Deutsche Telekom AG.</p>
</div>



</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
6 changes: 6 additions & 0 deletions _sources/api-reference/arangodb.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _aramgodb_code_doc:

:mod:`~mltb2.arangodb`
======================

.. automodule:: mltb2.arangodb
6 changes: 6 additions & 0 deletions _sources/api-reference/db.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _db_code_doc:

:mod:`~mltb2.db`
================

.. automodule:: mltb2.db
8 changes: 6 additions & 2 deletions api-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="data" href="api-reference/data.html" />
<link rel="next" title="arangodb" href="api-reference/arangodb.html" />
<link rel="prev" title="MLTB2 Documentation" href="index.html" />
</head>

Expand All @@ -50,7 +50,9 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">API Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="api-reference/arangodb.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">arangodb</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api-reference/data.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">data</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api-reference/db.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">db</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api-reference/fasttext.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">fasttext</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api-reference/files.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">files</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api-reference/md.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">md</span></code></a></li>
Expand Down Expand Up @@ -97,7 +99,9 @@
<h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this heading"></a></h1>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="api-reference/arangodb.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">arangodb</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="api-reference/data.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">data</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="api-reference/db.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">db</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="api-reference/fasttext.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">fasttext</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="api-reference/files.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">files</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="api-reference/md.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">md</span></code></a></li>
Expand All @@ -117,7 +121,7 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="index.html" class="btn btn-neutral float-left" title="MLTB2 Documentation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="api-reference/data.html" class="btn btn-neutral float-right" title="data" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="api-reference/arangodb.html" class="btn btn-neutral float-right" title="arangodb" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>

<hr/>
Expand Down
Loading

0 comments on commit 98980cc

Please sign in to comment.