generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 256242e
Showing
117 changed files
with
25,041 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 9fbfcbdaa80def9ef32635d9e97a9e35 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<!DOCTYPE html> | ||
<html class="writer-html5" lang="en" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>bdc.pipeline — Sales Lead Qualifier 01.00.00 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" /> | ||
|
||
|
||
<!--[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 src="../../_static/documentation_options.js?v=6386319a"></script> | ||
<script src="../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></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"> | ||
Sales Lead Qualifier | ||
</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"> | ||
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../readme_link.html">Sales-Lead-Qualifier Project (AMOS WS 2023/24)</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html">Build Documentation</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html#user-documentation">User Documentation</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html#design-documentation">Design Documentation</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html#classifier-comparison">Classifier Comparison</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html#concepts-unrealized-ideas-miscellaneous">Concepts, Unrealized Ideas & Miscellaneous</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</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">Sales Lead Qualifier</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">bdc.pipeline</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 bdc.pipeline</h1><div class="highlight"><pre> | ||
<span></span><span class="c1"># SPDX-License-Identifier: MIT</span> | ||
<span class="c1"># SPDX-FileCopyrightText: 2023 Lucca Baumgärtner <lucca.baumgaertner@fau.de></span> | ||
<span class="c1"># SPDX-FileCopyrightText: 2023 Sophie Heasman <sophieheasmann@gmail.com></span> | ||
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span> | ||
|
||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> | ||
|
||
<span class="kn">from</span> <span class="nn">bdc.steps.step</span> <span class="kn">import</span> <span class="n">Step</span><span class="p">,</span> <span class="n">StepError</span> | ||
<span class="kn">from</span> <span class="nn">database</span> <span class="kn">import</span> <span class="n">get_database</span> | ||
<span class="kn">from</span> <span class="nn">logger</span> <span class="kn">import</span> <span class="n">get_logger</span> | ||
|
||
<span class="n">log</span> <span class="o">=</span> <span class="n">get_logger</span><span class="p">()</span> | ||
|
||
|
||
<div class="viewcode-block" id="Pipeline"> | ||
<a class="viewcode-back" href="../../bdc.html#bdc.pipeline.Pipeline">[docs]</a> | ||
<span class="k">class</span> <span class="nc">Pipeline</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">steps</span><span class="p">,</span> | ||
<span class="n">limit</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="p">):</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">steps</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">Step</span><span class="p">]</span> <span class="o">=</span> <span class="n">steps</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">limit</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">limit</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">get_database</span><span class="p">()</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">()</span> | ||
|
||
<span class="k">if</span> <span class="n">limit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="p">[:</span><span class="n">limit</span><span class="p">]</span> | ||
|
||
<div class="viewcode-block" id="Pipeline.run"> | ||
<a class="viewcode-back" href="../../bdc.html#bdc.pipeline.Pipeline.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="n">run_id</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y/%m/</span><span class="si">%d</span><span class="s2">/%H%M%S/"</span><span class="p">)</span> | ||
<span class="n">error_occurred</span> <span class="o">=</span> <span class="kc">False</span> | ||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span> | ||
<span class="s2">"Error: DataFrame of pipeline has not been initialized, aborting pipeline run!"</span> | ||
<span class="p">)</span> | ||
<span class="k">return</span> | ||
|
||
<span class="c1"># helper to pass the dataframe and/or input location from previous step to next step</span> | ||
<span class="k">for</span> <span class="n">step</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">steps</span><span class="p">:</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Processing step </span><span class="si">{</span><span class="n">step</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> | ||
<span class="c1"># load dataframe and/or input location for this step</span> | ||
<span class="k">if</span> <span class="n">step</span><span class="o">.</span><span class="n">df</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="n">step</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> | ||
|
||
<span class="k">try</span><span class="p">:</span> | ||
<span class="n">step</span><span class="o">.</span><span class="n">load_data</span><span class="p">()</span> | ||
<span class="n">verified</span> <span class="o">=</span> <span class="n">step</span><span class="o">.</span><span class="n">verify</span><span class="p">()</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Verification for step </span><span class="si">{</span><span class="n">step</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">verified</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> | ||
<span class="n">data_present</span> <span class="o">=</span> <span class="n">step</span><span class="o">.</span><span class="n">check_data_presence</span><span class="p">()</span> | ||
<span class="k">if</span> <span class="n">verified</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">data_present</span><span class="p">:</span> | ||
<span class="n">step_df</span> <span class="o">=</span> <span class="n">step</span><span class="o">.</span><span class="n">run</span><span class="p">()</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">step_df</span> | ||
|
||
<span class="c1"># cleanup</span> | ||
<span class="n">step</span><span class="o">.</span><span class="n">finish</span><span class="p">()</span> | ||
<span class="k">except</span> <span class="p">(</span><span class="n">StepError</span><span class="p">,</span> <span class="ne">Exception</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> | ||
<span class="n">error_occurred</span> <span class="o">=</span> <span class="kc">True</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Step </span><span class="si">{</span><span class="n">step</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> failed! </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> | ||
<span class="k">finally</span><span class="p">:</span> | ||
<span class="c1"># Create snapshots to avoid data loss</span> | ||
<span class="n">get_database</span><span class="p">()</span><span class="o">.</span><span class="n">create_snapshot</span><span class="p">(</span><span class="n">step</span><span class="o">.</span><span class="n">df</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">run_id</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">step</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> | ||
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> | ||
|
||
<span class="c1"># Set dataframe in DAL</span> | ||
<span class="n">get_database</span><span class="p">()</span><span class="o">.</span><span class="n">set_dataframe</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="p">)</span> | ||
|
||
<span class="c1"># Upload DAL dataframe to chosen database</span> | ||
<span class="n">get_database</span><span class="p">()</span><span class="o">.</span><span class="n">save_dataframe</span><span class="p">()</span> | ||
|
||
<span class="c1"># Delete snapshots</span> | ||
<span class="k">if</span> <span class="ow">not</span> <span class="n">error_occurred</span><span class="p">:</span> | ||
<span class="n">get_database</span><span class="p">()</span><span class="o">.</span><span class="n">clean_snapshots</span><span class="p">(</span><span class="n">run_id</span><span class="p">)</span> | ||
|
||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Pipeline finished running </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">steps</span><span class="p">)</span><span class="si">}</span><span class="s2"> steps!"</span><span class="p">)</span></div> | ||
</div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
<footer> | ||
|
||
<hr/> | ||
|
||
<div role="contentinfo"> | ||
<p>© Copyright 2024, SumInsights.</p> | ||
</div> | ||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a | ||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> | ||
provided by <a href="https://readthedocs.org">Read the Docs</a>. | ||
|
||
|
||
</footer> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
<script> | ||
jQuery(function () { | ||
SphinxRtdTheme.Navigation.enable(true); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.