Skip to content

Commit

Permalink
Deploying to gh-pages from @ a53a796 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Action committed Mar 13, 2024
1 parent 7d27657 commit 117b3ab
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 6 deletions.
Binary file modified .doctrees/api.doctree
Binary file not shown.
Binary file modified .doctrees/changes/unreleased.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/user_guide/advanced.doctree
Binary file not shown.
Binary file modified .doctrees/user_guide/basics.doctree
Binary file not shown.
16 changes: 13 additions & 3 deletions _modules/exasol/bucketfs.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<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">hashlib</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">defaultdict</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="p">(</span>
Expand All @@ -272,7 +273,6 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="n">Iterator</span><span class="p">,</span>
<span class="n">Mapping</span><span class="p">,</span>
<span class="n">MutableMapping</span><span class="p">,</span>
<span class="n">Union</span><span class="p">,</span>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">urllib.parse</span> <span class="kn">import</span> <span class="n">urlparse</span>

Expand All @@ -284,12 +284,15 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="s2">&quot;Service&quot;</span><span class="p">,</span>
<span class="s2">&quot;Bucket&quot;</span><span class="p">,</span>
<span class="s2">&quot;MappedBucket&quot;</span><span class="p">,</span>
<span class="s2">&quot;BucketFsError&quot;</span><span class="p">,</span>
<span class="s2">&quot;as_bytes&quot;</span><span class="p">,</span>
<span class="s2">&quot;as_string&quot;</span><span class="p">,</span>
<span class="s2">&quot;as_file&quot;</span><span class="p">,</span>
<span class="s2">&quot;as_hash&quot;</span><span class="p">,</span>
<span class="p">]</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="s2">&quot;exasol.bucketfs&quot;</span><span class="p">)</span>


<div class="viewcode-block" id="BucketFsError"><a class="viewcode-back" href="../../api.html#exasol.bucketfs.BucketFsError">[docs]</a><span class="k">class</span> <span class="nc">BucketFsError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Error occurred while interacting with the bucket fs service.&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -337,7 +340,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<div class="viewcode-block" id="Service.__init__"><a class="viewcode-back" href="../../api.html#exasol.bucketfs.Service.__init__">[docs]</a> <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">url</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">credentials</span><span class="p">:</span> <span class="n">Mapping</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Mapping</span><span class="p">[</span><span class="nb">str</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="p">,</span>
<span class="n">credentials</span><span class="p">:</span> <span class="n">Mapping</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Mapping</span><span class="p">[</span><span class="nb">str</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">verify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Create a new Service instance.</span>
Expand Down Expand Up @@ -366,6 +369,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="n">url</span> <span class="o">=</span> <span class="n">_build_url</span><span class="p">(</span><span class="n">service_url</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_url</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_verify</span><span class="p">)</span>
<span class="k">try</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;Retrieving bucket list from </span><span class="si">{</span><span class="n">url</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
<span class="k">except</span> <span class="n">HTTPError</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">BucketFsError</span><span class="p">(</span>
Expand All @@ -386,7 +390,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<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>
<span class="k">return</span> <span class="sa">f</span><span class="s2">&quot;Service&lt;</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">&gt;&quot;</span>

<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Iterator</span><span class="p">[</span><span class="n">Bucket</span><span class="p">]:</span>
<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Iterator</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="k">yield from</span> <span class="bp">self</span><span class="o">.</span><span class="n">buckets</span>

<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Bucket</span><span class="p">:</span>
Expand Down Expand Up @@ -439,6 +443,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">files</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">_build_url</span><span class="p">(</span><span class="n">service_url</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_service</span><span class="p">,</span> <span class="n">bucket</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</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;Retrieving bucket listing for </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_auth</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_verify</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
Expand All @@ -462,6 +467,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="sd"> data: raw content of the file.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">_build_url</span><span class="p">(</span><span class="n">service_url</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_service</span><span class="p">,</span> <span class="n">bucket</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</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;Uploading </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> to bucket </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_auth</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_verify</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
Expand All @@ -479,6 +485,7 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="sd"> A BucketFsError if the operation couldn&#39;t be executed successfully.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">_build_url</span><span class="p">(</span><span class="n">service_url</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_service</span><span class="p">,</span> <span class="n">bucket</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</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;Deleting </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> from bucket </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_auth</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_verify</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
Expand All @@ -497,6 +504,9 @@ <h1>Source code for exasol.bucketfs</h1><div class="highlight"><pre>
<span class="sd"> An iterable of binary chunks representing the downloaded file.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">_build_url</span><span class="p">(</span><span class="n">service_url</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_service</span><span class="p">,</span> <span class="n">bucket</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</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;Downloading </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> using a chunk size of </span><span class="si">{</span><span class="n">chunk_size</span><span class="si">}</span><span class="s2"> bytes from bucket </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="p">)</span>
<span class="k">with</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
<span class="n">url</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_auth</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_verify</span>
<span class="p">)</span> <span class="k">as</span> <span class="n">response</span><span class="p">:</span>
Expand Down
22 changes: 22 additions & 0 deletions _sources/changes/unreleased.md.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Unreleased

## Added
- Added logging support
**Overview**

The bucketfs logger can be referenced via `exasol.bucketfs`

```python
import logging
# Get the logger for 'exasol.bucketfs'
logger = logging.getLogger('exasol.bucketfs')
```

For most use cases it should be sufficient to just configure the root logger, in order
to retrieve the logs from bucketfs.

```python
import logging

logging.basicConfig(level=logging.INFO)
```


## Internal
- Relock dependencies
- Update abatilo/actions-poetry from `v2.1.4` to `v3.0.0`
Expand Down
7 changes: 7 additions & 0 deletions _sources/user_guide/advanced.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ Delete files from Bucket
:start-after: # Expert/Mapped bucket API


Configure logging
+++++++++++++++++

.. literalinclude:: /examples/logger.py
:language: python3
:start-after: # Advanced Logging

7 changes: 7 additions & 0 deletions _sources/user_guide/basics.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@ Delete files from Bucket
:end-before: # Expert/Mapped bucket API


Configure logging
+++++++++++++++++

.. literalinclude:: /examples/logger.py
:language: python3
:end-before: # Advanced Logging

Loading

0 comments on commit 117b3ab

Please sign in to comment.