Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dscc-admin-ch committed Aug 2, 2024
1 parent 884d623 commit 2af7702
Show file tree
Hide file tree
Showing 37 changed files with 770 additions and 450 deletions.
4 changes: 3 additions & 1 deletion html/develop/en/_modules/lomas_server/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ <h1>Source code for lomas_server.app</h1><div class="highlight"><pre>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Loading query handler&quot;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">state</span><span class="o">.</span><span class="n">server_state</span><span class="p">[</span><span class="s2">&quot;message&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;Loading dataset store&quot;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">state</span><span class="o">.</span><span class="n">dataset_store</span> <span class="o">=</span> <span class="n">dataset_store_factory</span><span class="p">(</span>
<span class="n">config</span><span class="o">.</span><span class="n">dataset_store</span><span class="p">,</span> <span class="n">app</span><span class="o">.</span><span class="n">state</span><span class="o">.</span><span class="n">admin_database</span>
<span class="n">config</span><span class="o">.</span><span class="n">dataset_store</span><span class="p">,</span>
<span class="n">app</span><span class="o">.</span><span class="n">state</span><span class="o">.</span><span class="n">admin_database</span><span class="p">,</span>
<span class="n">config</span><span class="o">.</span><span class="n">private_db_credentials</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">app</span><span class="o">.</span><span class="n">state</span><span class="o">.</span><span class="n">server_state</span><span class="p">[</span><span class="s2">&quot;message&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;Loading query handler&quot;</span><span class="p">)</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@
<div itemprop="articleBody">

<h1>Source code for lomas_server.dataset_store.basic_dataset_store</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span>
<span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">List</span>

<span class="kn">from</span> <span class="nn">admin_database.admin_database</span> <span class="kn">import</span> <span class="n">AdminDatabase</span>
<span class="kn">from</span> <span class="nn">constants</span> <span class="kn">import</span> <span class="n">DPLibraries</span>
<span class="kn">from</span> <span class="nn">dataset_store.dataset_store</span> <span class="kn">import</span> <span class="n">DatasetStore</span>
<span class="kn">from</span> <span class="nn">dp_queries.dp_libraries.factory</span> <span class="kn">import</span> <span class="n">querier_factory</span>
<span class="kn">from</span> <span class="nn">dp_queries.dp_querier</span> <span class="kn">import</span> <span class="n">DPQuerier</span>
<span class="kn">from</span> <span class="nn">private_dataset.factory</span> <span class="kn">import</span> <span class="n">private_dataset_factory</span>
<span class="kn">from</span> <span class="nn">utils.config</span> <span class="kn">import</span> <span class="n">PrivateDBCredentials</span>


<div class="viewcode-block" id="BasicDatasetStore">
Expand All @@ -114,15 +115,20 @@ <h1>Source code for lomas_server.dataset_store.basic_dataset_store</h1><div clas

<span class="n">dp_queriers</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DPQuerier</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">,</span>
<span class="n">private_db_credentials</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">PrivateDBCredentials</span><span class="p">],</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;Initializer.</span>

<span class="sd"> Args:</span>
<span class="sd"> admin_database (AdminDatabase): An initialized AdminDatabase.</span>
<span class="sd"> private_db_credentials (List[PrivateDBCredentials]):\</span>
<span class="sd"> The private database credentials from the server config.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">admin_database</span><span class="p">)</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">admin_database</span><span class="p">,</span> <span class="n">private_db_credentials</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">dp_queriers</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span> <span class="o">=</span> <span class="n">admin_database</span>

<span class="k">def</span> <span class="nf">_add_dataset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataset_name</span><span class="p">:</span> <span class="nb">str</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;Adds a dataset to the manager.</span>
Expand All @@ -138,7 +144,7 @@ <h1>Source code for lomas_server.dataset_store.basic_dataset_store</h1><div clas

<span class="c1"># Metadata and data getter</span>
<span class="n">private_dataset</span> <span class="o">=</span> <span class="n">private_dataset_factory</span><span class="p">(</span>
<span class="n">dataset_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span>
<span class="n">dataset_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">private_db_credentials</span>
<span class="p">)</span>

<span class="c1"># Initialize dict</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@

<h1>Source code for lomas_server.dataset_store.dataset_store</h1><div class="highlight"><pre>
<span></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">typing</span> <span class="kn">import</span> <span class="n">List</span>

<span class="kn">from</span> <span class="nn">admin_database.admin_database</span> <span class="kn">import</span> <span class="n">AdminDatabase</span>
<span class="kn">from</span> <span class="nn">dp_queries.dp_querier</span> <span class="kn">import</span> <span class="n">DPQuerier</span>
<span class="kn">from</span> <span class="nn">utils.config</span> <span class="kn">import</span> <span class="n">PrivateDBCredentials</span>


<div class="viewcode-block" id="DatasetStore">
Expand All @@ -112,8 +114,20 @@ <h1>Source code for lomas_server.dataset_store.dataset_store</h1><div class="hig

<span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">,</span>
<span class="n">private_db_credentials</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">PrivateDBCredentials</span><span class="p">],</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;Initializer</span>

<span class="sd"> Args:</span>
<span class="sd"> admin_database (AdminDatabase): The admin database for the server.</span>
<span class="sd"> private_db_credentials (List[PrivateDBCredentials]):\</span>
<span class="sd"> The private database credentials from the server config.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span> <span class="o">=</span> <span class="n">admin_database</span>
<span class="bp">self</span><span class="o">.</span><span class="n">private_db_credentials</span> <span class="o">=</span> <span class="n">private_db_credentials</span>

<span class="nd">@abstractmethod</span>
<span class="k">def</span> <span class="nf">_add_dataset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataset_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

<h1>Source code for lomas_server.dataset_store.lru_dataset_store</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">OrderedDict</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span>

<span class="kn">from</span> <span class="nn">admin_database.admin_database</span> <span class="kn">import</span> <span class="n">AdminDatabase</span>
<span class="kn">from</span> <span class="nn">dataset_store.dataset_store</span> <span class="kn">import</span> <span class="n">DatasetStore</span>
Expand All @@ -100,6 +101,7 @@ <h1>Source code for lomas_server.dataset_store.lru_dataset_store</h1><div class=
<span class="kn">from</span> <span class="nn">dp_queries.dp_querier</span> <span class="kn">import</span> <span class="n">DPQuerier</span>
<span class="kn">from</span> <span class="nn">private_dataset.factory</span> <span class="kn">import</span> <span class="n">private_dataset_factory</span>
<span class="kn">from</span> <span class="nn">private_dataset.private_dataset</span> <span class="kn">import</span> <span class="n">PrivateDataset</span>
<span class="kn">from</span> <span class="nn">utils.config</span> <span class="kn">import</span> <span class="n">PrivateDBCredentials</span>
<span class="kn">from</span> <span class="nn">utils.error_handler</span> <span class="kn">import</span> <span class="n">InternalServerException</span>
<span class="kn">from</span> <span class="nn">utils.logger</span> <span class="kn">import</span> <span class="n">LOG</span>

Expand All @@ -118,17 +120,21 @@ <h1>Source code for lomas_server.dataset_store.lru_dataset_store</h1><div class=
<span class="n">dataset_cache</span><span class="p">:</span> <span class="n">OrderedDict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">PrivateDataset</span><span class="p">]</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span> <span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">,</span> <span class="n">max_memory_usage</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">admin_database</span><span class="p">:</span> <span class="n">AdminDatabase</span><span class="p">,</span>
<span class="n">private_db_credentials</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">PrivateDBCredentials</span><span class="p">],</span>
<span class="n">max_memory_usage</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1024</span><span class="p">,</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;Initializer.</span>

<span class="sd"> Args:</span>
<span class="sd"> admin_database (AdminDatabase): An initialized AdminDatabase.</span>
<span class="sd"> max_memory_usage (int, optional): Maximum memory usage limit</span>
<span class="sd"> max_memory_usage (int, optional): Maximum memory usage limit\</span>
<span class="sd"> for the manager.. Defaults to 1024.</span>
<span class="sd"> private_db_credentials (List[PrivateDBCredentials]):\</span>
<span class="sd"> The private database credentials from the server config.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">admin_database</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span> <span class="o">=</span> <span class="n">admin_database</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">admin_database</span><span class="p">,</span> <span class="n">private_db_credentials</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_memory_usage</span> <span class="o">=</span> <span class="n">max_memory_usage</span>

<span class="bp">self</span><span class="o">.</span><span class="n">dataset_cache</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span>
Expand All @@ -150,7 +156,7 @@ <h1>Source code for lomas_server.dataset_store.lru_dataset_store</h1><div class=

<span class="c1"># Make private dataset</span>
<span class="n">private_dataset</span> <span class="o">=</span> <span class="n">private_dataset_factory</span><span class="p">(</span>
<span class="n">dataset_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span>
<span class="n">dataset_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">admin_database</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">private_db_credentials</span>
<span class="p">)</span>
<span class="n">private_dataset</span><span class="o">.</span><span class="n">subscribe_for_memory_usage_updates</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

Expand Down
Loading

0 comments on commit 2af7702

Please sign in to comment.