<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Posts tagged: python</title>
  <id>https://pype.dev/tags/python/atom.xml</id>
  <updated>2025-09-08T11:25:33Z</updated>
  <subtitle>All posts with the tag &#34;python&#34;</subtitle>
  <link href="https://pype.dev/tags/python/" rel="alternate" type="text/html"></link>
  <link href="https://pype.dev/tags/python/atom.xml" rel="self" type="application/atom+xml"></link>
  <author>
    <name>Nic Payne</name>
  </author>
  <generator uri="https://github.com/WaylonWalker/markata-go">markata-go</generator>
  <entry>
    <title>💭 uv script management</title>
    <id>https://pype.dev/thoughts-831/</id>
    <updated>2025-09-08T11:25:33Z</updated>
    <published>2025-09-08T11:25:33Z</published>
    <link href="https://pype.dev/thoughts-831/" rel="alternate" type="text/html"></link>
    <summary type="text">Dang Waylon! Love these few lines... uv is great, been using it for environment and project requirements management bu</summary>
    <content type="html">&lt;a href=&#34;https://waylonwalker.com/uv-script-management/##sed+-i+&#39;1i+#!/usr/bin/env+-S+uv+run+--script&#39;+up&#34;&gt;&#xA;    &lt;img&#xA;        src=&#34;https://shots.wayl.one/shot/?url=https://waylonwalker.com/uv-script-management/##sed+-i+&#39;1i+#!/usr/bin/env+-S+uv+run+--script&#39;+up&amp;height=450&amp;width=800&amp;scaled_width=800&amp;scaled_height=450&amp;selectors=&#34;&#xA;        alt=&#34;shot of post - uv script management&#34;&#xA;        height=450&#xA;        width=800&#xA;    &gt;&#xA;&lt;/a&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s my thought on &lt;a href=&#34;https://waylonwalker.com/uv-script-management/##sed+-i+&#39;1i+#!/usr/bin/env+-S+uv+run+--script&#39;+up&#34;&gt;uv script management&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Dang Waylon! Love these few lines&amp;hellip; &lt;code&gt;uv&lt;/code&gt; is great, been using it for environment and project requirements management but I didn&amp;rsquo;t realize it was this easy to setup a pep 723 compliant script!&lt;/p&gt;&#xA;&lt;p&gt;Love this &lt;code&gt;sed -i &#39;1i #!/usr/bin/env -S uv run --script&#39;&lt;/code&gt; little gem too - I typically do &lt;code&gt;uv run script.py&lt;/code&gt; so I&amp;rsquo;ll see about making this a simple zsh alias for faster iteration on python scripts&amp;hellip; I often have AI write quick bash scripts to accomplish things, but it&amp;rsquo;s quite a bit harder for me to read than python, and with the power &lt;code&gt;uv&lt;/code&gt; is bringing to the python ecosystem, maybe it&amp;rsquo;s fine to just be a little higher in the programming stack for script-kitty stuff&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This is one of [[ my-thoughts ]]. I picked this up from &lt;a href=&#34;https://waylonwalker.com&#34;&gt;Waylon Walker&lt;/a&gt;(&lt;a href=&#34;https://thoughts.waylonwalker.com&#34;&gt;https://thoughts.waylonwalker.com&lt;/a&gt;). It&amp;rsquo;s a short note that I make about someone else&amp;rsquo;s content online.  Learn more about the process &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;My thoughts are found at my thoughts feed&#34; data-date=&#34;2025-06-09&#34; data-preview=&#34;My thoughts are found at my thoughts feed&#34;&gt;Thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Zsh alias for uv scripts</title>
    <id>https://pype.dev/zsh-alias-for-uv-scripts/</id>
    <updated>2025-09-08T06:33:13Z</updated>
    <published>2025-09-08T06:33:13Z</published>
    <link href="https://pype.dev/zsh-alias-for-uv-scripts/" rel="alternate" type="text/html"></link>
    <summary type="text">It&#39;s apparently advantageous for uv to have a specific shebang set that doesn&#39;t add, no problem, we can have a zsh alias for it</summary>
    <content type="html">&lt;p&gt;It&amp;rsquo;s apparently advantageous for &lt;a href=&#34;/uv/&#34; class=&#34;glossary-term&#34; title=&#34;uv by Astral.sh is one of the dopest python toolchain tools to ever exist&#34; data-hover-title=&#34;UV&#34;&gt;uv&lt;/a&gt; to have a specific shebang set that &lt;code&gt;uv init&lt;/code&gt; doesn&amp;rsquo;t add, no problem, we can have a zsh alias for it&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;alias&lt;/span&gt; add-shebang&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;f(){ &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;  if [[ ! -s $1 ]]; then &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;    echo &amp;#34;#!/usr/bin/env -S uv run --script&amp;#34; &amp;gt; &amp;#34;$1&amp;#34;; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;  elif head -n1 &amp;#34;$1&amp;#34; | grep -q &amp;#34;^#!&amp;#34;; then &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;    echo &amp;#34;Shebang already present in $1&amp;#34;; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;  else &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;    sed -i &amp;#34;1i #!/usr/bin/env -S uv run --script&amp;#34; &amp;#34;$1&amp;#34;; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;  fi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;}; f&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then if you have a python script from &lt;code&gt;uv init --script&lt;/code&gt; you can &lt;code&gt;add-shebang myscript.py&lt;/code&gt; to add the shebang.&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Python editable installs and nested scripts</title>
    <id>https://pype.dev/python-editable-installs-and-nested-scripts/</id>
    <updated>2025-07-14T08:40:32Z</updated>
    <published>2025-07-14T08:40:32Z</published>
    <link href="https://pype.dev/python-editable-installs-and-nested-scripts/" rel="alternate" type="text/html"></link>
    <summary type="text">I have been working towards a standard structure for all my python projects - and I mean much more than just or something along those lines. But one of the...</summary>
    <content type="html">&lt;h1 id=&#34;intro&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Intro&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I have been working towards a standard structure for all my python projects -&#xA;and I mean much more than just &lt;code&gt;uv init&lt;/code&gt; or something along those lines. But&#xA;one of the things that got me recently was starting to keep a &lt;code&gt;scripts/&lt;/code&gt; folder&#xA;that ran code based on what was in &lt;code&gt;src/&lt;/code&gt; or &lt;code&gt;app/&lt;/code&gt; (I&amp;rsquo;m working on that&amp;hellip;)&#xA;being installed in the virtual environment&amp;hellip; so I&amp;rsquo;d &lt;code&gt;uv pip install -e .&lt;/code&gt; or&#xA;&lt;code&gt;uv pip install -e src&lt;/code&gt; (&lt;a href=&#34;/kind/&#34; class=&#34;glossary-term&#34; title=&#34;kind - kubernetes in docker&#34; data-hover-title=&#34;kind&#34;&gt;kind&lt;/a&gt; of depends on the structure) and then in&#xA;&lt;code&gt;scripts/foo.py&lt;/code&gt; I&amp;rsquo;d have &lt;code&gt;from my_cool_code.module import thing&lt;/code&gt;&amp;hellip;.&lt;/p&gt;&#xA;&lt;p&gt;Running scripts has never been a problem&amp;hellip; but I&amp;rsquo;ve always kept them in the&#xA;root of the repo OR &lt;em&gt;inside&lt;/em&gt; &lt;code&gt;app&lt;/code&gt; or &lt;code&gt;src&lt;/code&gt; in a &lt;em&gt;nested&lt;/em&gt; directory&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;So here&amp;rsquo;s where I learned a little something about &lt;code&gt;python my_script.py&lt;/code&gt; vs&#xA;&lt;code&gt;python -m my_script&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Example&lt;/span&gt; &lt;a href=&#34;#example&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I setup a short example repo to illustrate the problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/pypeaday/python-e-example&#34;&gt;link to repo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The repo structure is very simple&amp;hellip;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;python-e-example&#xA;  ├── foo.py&#xA;  ├── pyproject.toml&#xA;  ├── src&#xA;  │   ├── module.py&#xA;  ├── README.md&#xA;  └── scripts&#xA;      └── bar.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;scripts/bar.py&lt;/code&gt; and &lt;code&gt;foo.py&lt;/code&gt; are the same code:&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;src.module&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;my_func&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;my_func&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and then &lt;code&gt;src/module.py&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;my_func&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;it worked!&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The rest of the structure is from &lt;code&gt;uv init&lt;/code&gt; basically, then &lt;code&gt;uv venv&lt;/code&gt; will make&#xA;your virtual environment, and &lt;code&gt;uv pip install -e .&lt;/code&gt; will install the library in&#xA;editable mode.&lt;/p&gt;&#xA;&lt;h3 id=&#34;so-what-s-the-problem&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;So what’s the problem?&lt;/span&gt; &lt;a href=&#34;#so-what-s-the-problem&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s run &lt;code&gt;foo.py&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nic in python-e-example   main   ×7 via   v3.13.1&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;python-e-example&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;   &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;dev&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; 󰒄&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;⬢ &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;devbox&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; ❯ python foo.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;it worked!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Nice! It works just like we&amp;rsquo;d expect&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;What about &lt;code&gt;python scripts/bar.py&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nic in python-e-example   main   ×7 via   v3.13.1&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;python-e-example&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;   &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;dev&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; 󰒄&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;⬢ &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;devbox&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; ❯ python scripts/bar.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Traceback &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;most recent call last&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  File &lt;span class=&#34;s2&#34;&gt;&amp;#34;/tmp/python-e-example/scripts/bar.py&amp;#34;&lt;/span&gt;, line 8, in &amp;lt;module&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    from src.module import my_func&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ModuleNotFoundError: No module named &lt;span class=&#34;s1&#34;&gt;&amp;#39;src&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&#34;admonition danger&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Come again for big fudge...&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;h3 id=&#34;ok-let-s-stay-calm-and-troubleshoot&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Ok let’s stay calm and troubleshoot&lt;/span&gt; &lt;a href=&#34;#ok-let-s-stay-calm-and-troubleshoot&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;What if we open a &lt;code&gt;python&lt;/code&gt; shell&amp;hellip;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Python 3.13.1 &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;main, Dec &lt;span class=&#34;m&#34;&gt;19&lt;/span&gt; 2024, 14:32:25&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;Clang 18.1.8 &lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; on linux&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Type &lt;span class=&#34;s2&#34;&gt;&amp;#34;help&amp;#34;&lt;/span&gt;, &lt;span class=&#34;s2&#34;&gt;&amp;#34;copyright&amp;#34;&lt;/span&gt;, &lt;span class=&#34;s2&#34;&gt;&amp;#34;credits&amp;#34;&lt;/span&gt; or &lt;span class=&#34;s2&#34;&gt;&amp;#34;license&amp;#34;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; more information.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt;&amp;gt;&amp;gt; from src.module import my_func&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt;&amp;gt;&amp;gt; my_func&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;lt;!--markata-attribution--&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;it worked!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;ok&amp;hellip; as expected it worked, and we&amp;rsquo;ve learned nothing&amp;hellip;&lt;/p&gt;&#xA;&lt;div class=&#34;admonition warning&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;implicit behavior&lt;/p&gt;&#xA;&lt;p&gt;We didn&amp;rsquo;t learn anything from the example but something is present that we&#xA;don&amp;rsquo;t see&amp;hellip; &lt;code&gt;python foo.py&lt;/code&gt; implicitly adds the path to the script to&#xA;&lt;code&gt;sys.path&lt;/code&gt; and so the &lt;code&gt;src&lt;/code&gt; library is in the same directory as the script&#xA;&lt;code&gt;foo.py&lt;/code&gt; so the library is on &lt;code&gt;sys.path&lt;/code&gt;&amp;hellip;. take note of this&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;The Problem&lt;/span&gt; &lt;a href=&#34;#the-problem&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Turns out &lt;code&gt;uv pip install .&lt;/code&gt; and &lt;code&gt;uv pip install -e .&lt;/code&gt; are &lt;em&gt;actually&lt;/em&gt; different&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://cdn.statically.io/gh/pypeaday/images.pype.dev/main/blog-media/20250705005214_a83dd563.png&#34; alt=&#34;20250705005214_a83dd563.png&#34;&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;The editable install adds a &lt;code&gt;.pth&lt;/code&gt; file into &lt;code&gt;site-packages&lt;/code&gt; which acts as a&#xA;shell hook.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# .venv/lib/python3.13/site-packages/__editable__.python_e_example-0.1.0.pth&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;/tmp/python-e-example/src&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So when &lt;code&gt;python&lt;/code&gt; runs a script, the location of the script is&#xA;implicitly added to &lt;code&gt;sys.path&lt;/code&gt; as noted above.&#xA;The &lt;code&gt;python&lt;/code&gt; process invoked by &lt;code&gt;python foo.py&lt;/code&gt; has &lt;code&gt;$PWD&lt;/code&gt; on &lt;code&gt;sys.path&lt;/code&gt; which is &lt;code&gt;/tmp/python-e-example&lt;/code&gt; in&#xA;the example but &lt;code&gt;python scripts/bar.py&lt;/code&gt; has &lt;code&gt;/tmp/python-e-example/scripts&lt;/code&gt;&#xA;on &lt;code&gt;sys.path&lt;/code&gt;&amp;hellip; which means that &lt;code&gt;/tmp/python-e-example&lt;/code&gt; is NOT on &lt;code&gt;sys.path&lt;/code&gt;&#xA;in the process that&amp;rsquo;s running &lt;code&gt;scripts/bar.py&lt;/code&gt; and so the &lt;code&gt;src&lt;/code&gt; folder won&amp;rsquo;t be&#xA;searched by python because the &lt;code&gt;.pth&lt;/code&gt; file points to a directory that&amp;rsquo;s no on&#xA;the path!&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-solution&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;The Solution&lt;/span&gt; &lt;a href=&#34;#the-solution&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;We can instead of running the script &amp;ldquo;as a script&amp;rdquo; we can tell python to&#xA;execute it as as a module with &lt;code&gt;python -m scripts.bar&lt;/code&gt;. This is syntatically&#xA;similar to &lt;code&gt;python path/to/script.py&lt;/code&gt; but instead tells the python interpreter&#xA;to execute the script as a module so the path is replaced by import syntax.&lt;/p&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;This works for foo.py too&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;⬢ &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;devbox&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; ✗ python -m foo&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;it worked!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;⬢ &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;devbox&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; ❯ python -m scripts.bar&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;it worked!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;chatgpt&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;ChatGPT&lt;/span&gt; &lt;a href=&#34;#chatgpt&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s noteworthy that jipity was helpful in exploring these issues I was running into&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://chatgpt.com/c/686d2a05-5b54-800f-8b84-1638c1b96840&#34;&gt;link to convo&lt;/a&gt;&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>💭 Build backend | uv</title>
    <id>https://pype.dev/thoughts-732/</id>
    <updated>2025-07-04T11:43:30Z</updated>
    <published>2025-07-04T11:43:30Z</published>
    <link href="https://pype.dev/thoughts-732/" rel="alternate" type="text/html"></link>
    <summary type="text">uv build backend ready for production! Dang... I need to visit my hatch builds, I love hatch&#39;s simplicity specifically w</summary>
    <content type="html">&lt;a href=&#34;https://docs.astral.sh/uv/concepts/build-backend/&#34;&gt;&#xA;    &lt;img&#xA;        src=&#34;https://shots.wayl.one/shot/?url=https://docs.astral.sh/uv/concepts/build-backend/&amp;height=450&amp;width=800&amp;scaled_width=800&amp;scaled_height=450&amp;selectors=&#34;&#xA;        alt=&#34;shot of post - Build backend | uv&#34;&#xA;        height=450&#xA;        width=800&#xA;    &gt;&#xA;&lt;/a&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s my thought on &lt;a href=&#34;https://docs.astral.sh/uv/concepts/build-backend/&#34;&gt;Build backend | uv&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;a href=&#34;/uv/&#34; class=&#34;glossary-term&#34; title=&#34;uv by Astral.sh is one of the dopest python toolchain tools to ever exist&#34; data-hover-title=&#34;UV&#34;&gt;uv&lt;/a&gt; build backend ready for production! Dang&amp;hellip; I need to visit my hatch builds, I love hatch&amp;rsquo;s simplicity specifically with versioning&amp;hellip;  Not sure if it&amp;rsquo;s worth actually switching to uv for my builds or not, but it is dang cool to see astral take on the python space with unbelievable improvements&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This is one of [[ my-thoughts ]]. I picked this up from &lt;a href=&#34;https://waylonwalker.com&#34;&gt;Waylon Walker&lt;/a&gt;(&lt;a href=&#34;https://thoughts.waylonwalker.com&#34;&gt;https://thoughts.waylonwalker.com&lt;/a&gt;). It&amp;rsquo;s a short note that I make about someone else&amp;rsquo;s content online.  Learn more about the process &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;My thoughts are found at my thoughts feed&#34; data-date=&#34;2025-06-09&#34; data-preview=&#34;My thoughts are found at my thoughts feed&#34;&gt;Thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>💭 Switching pip to uv in a Dockerized Flask / Django App — Nick …</title>
    <id>https://pype.dev/thoughts-722/</id>
    <updated>2025-06-27T11:18:16Z</updated>
    <published>2025-06-27T11:18:16Z</published>
    <link href="https://pype.dev/thoughts-722/" rel="alternate" type="text/html"></link>
    <summary type="text">It&#39;s nice to see uv gaining popularity in so many places - and replacing vanilla pip with uv in containerized environmen</summary>
    <content type="html">&lt;a href=&#34;https://nickjanetakis.com/blog/switching-pip-to-uv-in-a-dockerized-flask-or-django-app&#34;&gt;&#xA;    &lt;img&#xA;        src=&#34;https://shots.wayl.one/shot/?url=https://nickjanetakis.com/blog/switching-pip-to-uv-in-a-dockerized-flask-or-django-app&amp;height=450&amp;width=800&amp;scaled_width=800&amp;scaled_height=450&amp;selectors=&#34;&#xA;        alt=&#34;shot of post - Switching pip to uv in a Dockerized Flask / Django App — Nick Janetakis&#34;&#xA;        height=450&#xA;        width=800&#xA;    &gt;&#xA;&lt;/a&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s my thought on &lt;a href=&#34;https://nickjanetakis.com/blog/switching-pip-to-uv-in-a-dockerized-flask-or-django-app&#34;&gt;Switching pip to uv in a Dockerized Flask / Django App — Nick Janetakis&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;It&amp;rsquo;s nice to see &lt;a href=&#34;/uv/&#34; class=&#34;glossary-term&#34; title=&#34;uv by Astral.sh is one of the dopest python toolchain tools to ever exist&#34; data-hover-title=&#34;UV&#34;&gt;uv&lt;/a&gt; gaining popularity in so many places - and replacing vanilla pip with uv in containerized environments seems great due if for no other reason than the time you&amp;rsquo;ll save in CI&amp;hellip; A few years ago I refactored a disjointed container build process to use uv instead of pip, and due to the design of the build pipelines we went from 10-15 minute builds to 2-3 minutes&amp;hellip;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This is one of [[ my-thoughts ]]. I picked this up from &lt;a href=&#34;https://waylonwalker.com&#34;&gt;Waylon Walker&lt;/a&gt;(&lt;a href=&#34;https://thoughts.waylonwalker.com&#34;&gt;https://thoughts.waylonwalker.com&lt;/a&gt;). It&amp;rsquo;s a short note that I make about someone else&amp;rsquo;s content online.  Learn more about the process &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;My thoughts are found at my thoughts feed&#34; data-date=&#34;2025-06-09&#34; data-preview=&#34;My thoughts are found at my thoughts feed&#34;&gt;Thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>💭 Snowflake Status - Certificate Authority Update for AWS Regions</title>
    <id>https://pype.dev/thoughts-698/</id>
    <updated>2025-06-16T16:37:12Z</updated>
    <published>2025-06-16T16:37:12Z</published>
    <link href="https://pype.dev/thoughts-698/" rel="alternate" type="text/html"></link>
    <summary type="text">A recent Snowflake issue borked some old pipelines - thankfully it appears to be a simple fix. Just goes to show you tha</summary>
    <content type="html">&lt;a href=&#34;https://status.snowflake.com/incidents/txclg2cyzq32&#34;&gt;&#xA;    &lt;img&#xA;        src=&#34;https://shots.wayl.one/shot/?url=https://status.snowflake.com/incidents/txclg2cyzq32&amp;height=450&amp;width=800&amp;scaled_width=800&amp;scaled_height=450&amp;selectors=&#34;&#xA;        alt=&#34;shot of post - Snowflake Status - Certificate Authority Update for AWS Regions&#34;&#xA;        height=450&#xA;        width=800&#xA;    &gt;&#xA;&lt;/a&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s my thought on &lt;a href=&#34;https://status.snowflake.com/incidents/txclg2cyzq32&#34;&gt;Snowflake Status - Certificate Authority Update for AWS Regions&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;A recent Snowflake issue borked some old pipelines - thankfully it appears to be a simple fix. Just goes to show you that you can&amp;rsquo;t just deploy pipelines and expect them to live forever, they have to be maintained when there are ANY external dependencies&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This is one of [[ my-thoughts ]]. I picked this up from &lt;a href=&#34;https://waylonwalker.com&#34;&gt;Waylon Walker&lt;/a&gt;(&lt;a href=&#34;https://thoughts.waylonwalker.com&#34;&gt;https://thoughts.waylonwalker.com&lt;/a&gt;). It&amp;rsquo;s a short note that I make about someone else&amp;rsquo;s content online.  Learn more about the process &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;My thoughts are found at my thoughts feed&#34; data-date=&#34;2025-06-09&#34; data-preview=&#34;My thoughts are found at my thoughts feed&#34;&gt;Thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>I built a simple app for adding images to my blog</title>
    <id>https://pype.dev/i-built-a-simple-app-for-adding-images-to-my-blog/</id>
    <updated>2025-06-07T13:30:28Z</updated>
    <published>2025-06-07T13:30:28Z</published>
    <link href="https://pype.dev/i-built-a-simple-app-for-adding-images-to-my-blog/" rel="alternate" type="text/html"></link>
    <summary type="text">I built a simple fastAPI app called &#34;shotput&#34; that I run locally inside a git repo where I save images for my blog. The app is simple:</summary>
    <content type="html">&lt;h1 id=&#34;quick-deets&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Quick Deets&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I built a simple fastAPI app called &amp;ldquo;shotput&amp;rdquo; that I run locally inside a git repo where I save images for my blog. The app is simple:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;upload image from clipboard&lt;/li&gt;&#xA;&lt;li&gt;app commits image to repo (path is configurable)&lt;/li&gt;&#xA;&lt;li&gt;app pushes the commit (auto-push configurable)&lt;/li&gt;&#xA;&lt;li&gt;app returns a markdown link I can paste in my blog that uses statically.io (see &lt;a href=&#34;/statically-io-to-help-me-out/&#34; class=&#34;wikilink&#34; data-title=&#34;statically.io to help me out&#34; data-description=&#34;statically.io offers a CDN that I&amp;#39;m going to try to lean into for images in my blog. My hope is that the builds get and stay fast, and that page loads are...&#34; data-date=&#34;2024-12-14&#34; data-preview=&#34;statically.io offers a CDN that I&amp;#39;m going to try to lean into for images in my blog. My hope is that the builds get and stay fast, and that page loads are...&#34;&gt;statically.io to help me out&lt;/a&gt;) to serve the image from the repo to my blog&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;See the image repo with app details at &lt;a href=&#34;https://github.com/pypeaday/images.pype.dev&#34;&gt;images.pype.dev&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;usage&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Usage&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Anyone could copy the script and config to their own git repo to put images in&#xA;and run this at home - instructions are in the readme but for simple running on localhost it&amp;rsquo;s just &lt;code&gt;uv run&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;example&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Example&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://cdn.statically.io/gh/pypeaday/images.pype.dev/main/blog-media/20250607130609_dadd33eb.png&#34; alt=&#34;20250607130609_dadd33eb.png&#34;&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;pasting an image let&amp;rsquo;s you copy the markdown link for easy pasting&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;![&lt;span class=&#34;nt&#34;&gt;20250607130609_dadd33eb.png&lt;/span&gt;](&lt;span class=&#34;na&#34;&gt;https://cdn.statically.io/gh/pypeaday/images.pype.dev/main/blog-media/20250607130609_dadd33eb.png&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Pandas.DataFrame info always answers and is sometimes right</title>
    <id>https://pype.dev/pandas-dataframe-info-always-answers-and-is-sometimes-right/</id>
    <updated>2025-05-26T09:08:08Z</updated>
    <published>2025-05-26T09:08:08Z</published>
    <link href="https://pype.dev/pandas-dataframe-info-always-answers-and-is-sometimes-right/" rel="alternate" type="text/html"></link>
    <summary type="text">Today I learned that the of a will always give you an answer, but it is wildly difficult to know how accurate it is, because it depends on the underlying...</summary>
    <content type="html">&lt;h1 id=&#34;til&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;TIL&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Today I learned that the &lt;code&gt;.info()&lt;/code&gt; of a &lt;code&gt;pandas.DataFrame&lt;/code&gt; will always&#xA;give you an answer, but it is wildly difficult to know how accurate it is, because it depends&#xA;on the underlying data types.&#xA;If everything is a NumPy Dtype, then the result you get is the amount of memory NumPy is using&#xA;under the hood, which is very accurate.&#xA;But as soon as you have something like a Python string in the data frame, now pandas will&#xA;tell you how much memory the NumPy data types are using, and it will give you some quick&#xA;estimate of how much memory space the Python string types are using because numpy is just storing&#xA;a pointer to that data in memory, but this is far less&#xA;accurate because it doesn&amp;rsquo;t actually know what the strings are.&lt;/p&gt;&#xA;&lt;h2 id=&#34;memory-usage-deep-or-true&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Memory Usage Deep or True&lt;/span&gt; &lt;a href=&#34;#memory-usage-deep-or-true&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;To get an honest answer about a DataFrame&amp;rsquo;s memory usage, you need to pass &lt;code&gt;memory_usage=&#39;deep&#39;&lt;/code&gt; to the &lt;code&gt;.info()&lt;/code&gt; method.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# This is the default&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;In &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;50&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;: df.info&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;memory_usage&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;True&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;lt;class &lt;span class=&#34;s1&#34;&gt;&amp;#39;pandas.core.frame.DataFrame&amp;#39;&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;RangeIndex: &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; entries, &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; to &lt;span class=&#34;m&#34;&gt;9&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Data columns &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;total &lt;span class=&#34;m&#34;&gt;3&lt;/span&gt; columns&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;c1&#34;&gt;#   Column  Non-Null Count  Dtype &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;---  ------  --------------  ----- &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt;   s1      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     int64 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt;   s2      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     int64 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;   s3      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     object&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dtypes: int64&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;2&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;, object&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;1&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;memory usage: 372.0+ bytes&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Notice that the memory usage has a &lt;code&gt;+&lt;/code&gt; in it? You can force a deeper analysis by passing &lt;code&gt;memory_usage=&#39;deep&#39;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;In &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;51&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;: df.info&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;memory_usage&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;deep&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;lt;class &lt;span class=&#34;s1&#34;&gt;&amp;#39;pandas.core.frame.DataFrame&amp;#39;&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;RangeIndex: &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; entries, &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; to &lt;span class=&#34;m&#34;&gt;9&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Data columns &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;total &lt;span class=&#34;m&#34;&gt;3&lt;/span&gt; columns&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;c1&#34;&gt;#   Column  Non-Null Count  Dtype &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;---  ------  --------------  ----- &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt;   s1      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     int64 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt;   s2      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     int64 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;   s3      &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; non-null     object&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dtypes: int64&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;2&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;, object&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;1&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;memory usage: 792.0 bytes&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>My MCP Configuration</title>
    <id>https://pype.dev/my-mcp-configuration/</id>
    <updated>2025-04-27T05:29:54Z</updated>
    <published>2025-04-27T05:29:54Z</published>
    <link href="https://pype.dev/my-mcp-configuration/" rel="alternate" type="text/html"></link>
    <summary type="text">https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite</summary>
    <content type="html">&lt;h1 id=&#34;my-mcp&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;My MCP&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;h2 id=&#34;the-tools&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;The Tools&lt;/span&gt; &lt;a href=&#34;#the-tools&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;docker&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;&lt;a href=&#34;/docker/&#34; class=&#34;glossary-term&#34; title=&#34;docker - container runtime&#34; data-hover-title=&#34;docker&#34;&gt;Docker&lt;/a&gt;&lt;/span&gt; &lt;a href=&#34;#docker&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;h3 id=&#34;ragdocs&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;RAGDocs&lt;/span&gt; &lt;a href=&#34;#ragdocs&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;h3 id=&#34;sequential-thinking&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Sequential Thinking&lt;/span&gt; &lt;a href=&#34;#sequential-thinking&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;h3 id=&#34;git&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Git&lt;/span&gt; &lt;a href=&#34;#git&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;h3 id=&#34;not-tried-yet&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Not Tried Yet&lt;/span&gt; &lt;a href=&#34;#not-tried-yet&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite&#34;&gt;https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-config&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;The Config&lt;/span&gt; &lt;a href=&#34;#the-config&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nt&#34;&gt;&amp;#34;mcpServers&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;docker-mcp&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nt&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;uvx&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nt&#34;&gt;&amp;#34;args&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;          &lt;span class=&#34;s2&#34;&gt;&amp;#34;docker-mcp&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;},&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;ragdocs&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;node&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;args&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;/home/nic/projects/personal/quadtask/node_modules/@qpd-v/mcp-server-ragdocs/build/index.js&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;],&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;env&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nt&#34;&gt;&amp;#34;QDRANT_URL&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;http://babyblue-aurora:6333&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nt&#34;&gt;&amp;#34;EMBEDDING_PROVIDER&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;ollama&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nt&#34;&gt;&amp;#34;OLLAMA_URL&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;http://babyblue-aurora:11434&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;},&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;alwaysAllow&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;search_documentation&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;list_sources&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;test_ollama&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;add_documentation&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;],&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;disabled&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;},&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;sequentialthinking&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;docker&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;args&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;run&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;--rm&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;-i&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;--name&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;sequentialthinking&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;mcp/sequentialthinking&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;],&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;disabled&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;alwaysAllow&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;sequentialthinking&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;},&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;git&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;uvx&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;args&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;mcp-server-git&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;],&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;disabled&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;alwaysAllow&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;git_status&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;git_commit&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;git_add&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;git_log&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;git_diff&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>docker context (and an issue to question your sanity)</title>
    <id>https://pype.dev/docker-context-and-an-issue-to-question-your-sanity/</id>
    <updated>2024-12-19T05:59:30Z</updated>
    <published>2024-12-19T05:59:30Z</published>
    <link href="https://pype.dev/docker-context-and-an-issue-to-question-your-sanity/" rel="alternate" type="text/html"></link>
    <summary type="text">docker contexts are great, would recommend putting them in your prompt though (via starship or something else)... here&#39;s why</summary>
    <content type="html">&lt;p&gt;&lt;a href=&#34;/docker/&#34; class=&#34;glossary-term&#34; title=&#34;docker - container runtime&#34; data-hover-title=&#34;docker&#34;&gt;docker&lt;/a&gt; contexts are great, would recommend putting them in your prompt though (via starship or something else)&amp;hellip; here&amp;rsquo;s why&lt;/p&gt;&#xA;&lt;p&gt;I like to manage my containers remotely - I have a nice development setup on my desktop and I try to keep my server as bare-bones as possible. For a while I&amp;rsquo;ve been using ansible which makes it easy to manage configuration etc on other machines. But I recently learned about docker contexts and I&amp;rsquo;m planning to scale down my homelab management to just docker-compose stacks rather than a bunch of super complicated ansible playbooks&lt;/p&gt;&#xA;&lt;p&gt;So, setting up a context is easy - it&amp;rsquo;s basically an ssh connection to another machine!&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;docker context create koober --docker &amp;quot;host=ssh://nic@koober&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;koober&lt;/code&gt; is one of my dev machines and my &lt;code&gt;~/.ssh/config&lt;/code&gt; is setup such that I can &lt;code&gt;ssh nic@koober&lt;/code&gt;, this makes the context work really seamlessly.&lt;/p&gt;&#xA;&lt;p&gt;So there&amp;rsquo;s the &lt;code&gt;default&lt;/code&gt; context (the machine you&amp;rsquo;re on) and now I have &lt;code&gt;koober&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;To use it you run &lt;code&gt;docker context use koober&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then to check we can &lt;code&gt;ls&lt;/code&gt; the contexts&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;docker context ls&#xA;NAME       DESCRIPTION                               DOCKER ENDPOINT               ERROR&#xA;default    Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   &#xA;koober *                                             ssh://nic@koober&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Notice the * - that indicates that&amp;rsquo;s our current context.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;trouble&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Trouble&lt;/span&gt; &lt;a href=&#34;#trouble&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now here&amp;rsquo;s where things get hairy&amp;hellip; you&amp;rsquo;ve gotta be super-aware of what context you&amp;rsquo;re using. I have an indicator in my starship prompt that shows the current context, but since I&amp;rsquo;m new to using them I &lt;a href=&#34;/kind/&#34; class=&#34;glossary-term&#34; title=&#34;kind - kubernetes in docker&#34; data-hover-title=&#34;kind&#34;&gt;kind&lt;/a&gt; of didn&amp;rsquo;t notice it until I ran into this issue&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m working on a python application in docker but was not able to execute the entrypoint even though I KNEW the file was there&amp;hellip; let&amp;rsquo;s take a look&lt;/p&gt;&#xA;&lt;h3 id=&#34;example&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Example&lt;/span&gt; &lt;a href=&#34;#example&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s a minimal hello world applycation in docker to illustrate the issue&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# main.py&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;hello world&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Use an official Python runtime as a parent image&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;FROM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;python:3.11-slim&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Set the working directory in the container&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;WORKDIR&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;/app&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Copy the current directory contents into the container at /app&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;COPY&lt;/span&gt; . /app&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Run the main.py script as the container&amp;#39;s main process&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;CMD&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;python&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;main.py&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;services&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;hello-world&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;build&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;volumes&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;- &lt;span class=&#34;l&#34;&gt;.:/app&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Notice volume mounting in my project directory &lt;code&gt;.&lt;/code&gt; to &lt;code&gt;/app&lt;/code&gt; as a common practice to develop inside the container&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s where I started to question my sanity&amp;hellip;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;✗ docker compose up                                            &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;+&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Running 1/0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; ✔ Container docker-context-example-hello-world-1  Created                                                                                                                                                                                                                                                              0.0s &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Attaching to hello-world-1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;hello-world-1  &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; python: can&lt;span class=&#34;s1&#34;&gt;&amp;#39;t open file &amp;#39;&lt;/span&gt;/app/main.py&lt;span class=&#34;err&#34;&gt;&amp;#39;&lt;/span&gt;: &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;Errno 2&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; No such file or directory&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;hello-world-1 exited with code &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;python can&#39;t open file&lt;/code&gt;? hmm&amp;hellip; Let&amp;rsquo;s take a look at the image&lt;/p&gt;&#xA;&lt;p&gt;First let&amp;rsquo;s make sure we get the image name right&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;✗ docker container ls -a              &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;CONTAINER ID   IMAGE                                           COMMAND                  CREATED          STATUS                       PORTS                                                                                  NAMES&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;3d7285fc39e2   docker-context-example-hello-world              &lt;span class=&#34;s2&#34;&gt;&amp;#34;python main.py&amp;#34;&lt;/span&gt;         &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt; minutes ago   Exited &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;2&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;44&lt;/span&gt; seconds ago                                                                                           docker-context-example-hello-world-1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now we can &lt;code&gt;docker run --rm -it --entrypoint /bin/bash --name debug docker-context-example-hello-world&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;❯ docker run --rm -it --entrypoint /bin/bash --name debug docker-context-example-hello-world  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@ee46d0e22de8:/app# python main.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Hello, World!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@ee46d0e22de8:/app# &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;WHAT THE HECK??&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-happened&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;What happened…&lt;/span&gt; &lt;a href=&#34;#what-happened&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;What happened turns out to be pretty simple once we realize I&amp;rsquo;m using contexts&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;koboer&lt;/code&gt; is a remote context, the &lt;code&gt;docker run&lt;/code&gt; and &lt;code&gt;docker compose up&lt;/code&gt; commands are interacting with the docker socket on that machine.&lt;/p&gt;&#xA;&lt;p&gt;So if I compose up the stack notice that there&amp;rsquo;s a volume bind mount in there - well those do &lt;em&gt;not&lt;/em&gt; work with contexts (or at least I&amp;rsquo;m not aware of hose to make it work) and so the &lt;code&gt;/app&lt;/code&gt; directory was getting blown away essentially with an empty overlay&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;But when running with just &lt;code&gt;docker run&lt;/code&gt; with no volume mount, the code was copied in during the build and is right where we expect it&amp;hellip;&lt;/p&gt;&#xA;&lt;h3 id=&#34;let-s-prove-it&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Let’s prove it&lt;/span&gt; &lt;a href=&#34;#let-s-prove-it&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;❯ docker run --rm -it --entrypoint /bin/bash --name debug -v .:/app docker-context-example-hello-world&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@903f591c0384:/app# python main.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;python: can&lt;span class=&#34;s1&#34;&gt;&amp;#39;t open file &amp;#39;&lt;/span&gt;/app/main.py&lt;span class=&#34;err&#34;&gt;&amp;#39;&lt;/span&gt;: &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;Errno 2&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; No such file or directory&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@903f591c0384:/app# &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;Adding a `-v .:/app` to match the compose file, we get the same error...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If we switch to the default context we are back up and running as expected&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;✗ docker context use default&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;default&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Current context is now &lt;span class=&#34;s2&#34;&gt;&amp;#34;default&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nic in /tmp/docker-context-example  via   v3.13.0  &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;dev&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; 󰒄 󱔎 NO PYTHON ENVIORNMENT SET &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;❯ docker compose up         &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;+&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Running 1/0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; ✔ Container docker-context-example-hello-world-1  Created                                                                                                                                                                                                                                                              0.0s &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Attaching to hello-world-1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;hello-world-1  &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; Hello, World!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;hello-world-1 exited with code &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nic in /tmp/docker-context-example  via   v3.13.0  &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;dev&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; 󰒄 󱔎 NO PYTHON ENVIORNMENT SET &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;❯ docker run --rm -it --entrypoint /bin/bash --name debug -v .:/app docker-context-example-hello-world&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@4045b6aa8883:/app# python main.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Hello, World!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root@4045b6aa8883:/app# &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Successful runs on both accounts with the volume mount&lt;/p&gt;&#xA;&lt;h2 id=&#34;tldr&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;TLDR&lt;/span&gt; &lt;a href=&#34;#tldr&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Context is king&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Add a healthcheck to your FastAPI app</title>
    <id>https://pype.dev/add-a-healthcheck-to-your-fastapi-app/</id>
    <updated>2024-12-15T15:41:36Z</updated>
    <published>2024-12-15T15:41:36Z</published>
    <link href="https://pype.dev/add-a-healthcheck-to-your-fastapi-app/" rel="alternate" type="text/html"></link>
    <summary type="text">I&#39;m building a few FastAPI apps to throw in docker and run on my homelab... I wanted to add healthchecks and here&#39;s a simple way to do it</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;m building a few FastAPI apps to throw in &lt;a href=&#34;/docker/&#34; class=&#34;glossary-term&#34; title=&#34;docker - container runtime&#34; data-hover-title=&#34;docker&#34;&gt;docker&lt;/a&gt; and run on my homelab&amp;hellip; I wanted to add healthchecks and here&amp;rsquo;s a simple way to do it&lt;/p&gt;&#xA;&lt;p&gt;Make sure to install &lt;code&gt;curl&lt;/code&gt; in the dockerfile (near the top for effeciency)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Install curl with minimal dependencies&#xA;RUN apt-get update &amp;amp;&amp;amp; \&#xA;    apt-get install -y --no-install-recommends curl &amp;amp;&amp;amp; \&#xA;    apt-get clean &amp;amp;&amp;amp; \&#xA;    rm -rf /var/lib/apt/lists/*&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I recommend making compose files even for single image deployments&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;services:&#xA;  app:&#xA;    build: .&#xA;    volumes:&#xA;      - type: bind&#xA;        source: .&#xA;        target: /app&#xA;    environment:&#xA;      - PYTHONPATH=/app&#xA;      - DOCKER_ENV=true&#xA;      - UV_VIRTUALENV=/opt/app-env&#xA;    user: &amp;quot;1000:1000&amp;quot;&#xA;    restart: unless-stopped&#xA;    healthcheck:&#xA;      test: [&amp;quot;CMD&amp;quot;, &amp;quot;curl&amp;quot;, &amp;quot;-f&amp;quot;, &amp;quot;http://localhost:8000/health&amp;quot;]&#xA;      interval: 30s&#xA;      timeout: 10s&#xA;      retries: 3&#xA;      start_period: 10s&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then finally you&amp;rsquo;ll need a &lt;code&gt;/health&lt;/code&gt; endpoint&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@app.get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/health&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;response_class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;health_check&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;#34;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;    A health check endpoint that returns a status message.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;    &amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Service is healthy&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Switching from AltaCV to RenderCV for my Resume</title>
    <id>https://pype.dev/switching-from-altacv-to-rendercv-for-my-resume/</id>
    <updated>2024-08-01T05:59:46Z</updated>
    <published>2024-08-01T05:59:46Z</published>
    <link href="https://pype.dev/switching-from-altacv-to-rendercv-for-my-resume/" rel="alternate" type="text/html"></link>
    <summary type="text">I was using a fun LaTex-based project for managing my resume called AltaCV. I loved the customization and was familiar with Tek from school. However, I...</summary>
    <content type="html">&lt;p&gt;I was using a fun LaTex-based project for managing my resume called &lt;a href=&#34;https://github.com/liantze/AltaCV&#34;&gt;AltaCV&lt;/a&gt;. I loved the customization and was familiar with Tek from school. However, I update my resume so infrequently that anytime I&amp;rsquo;d hop back to it I&amp;rsquo;d have to remember how to work with Tex and that was frustrating as I&amp;rsquo;ve lost touch with it over the years.&lt;/p&gt;&#xA;&lt;p&gt;Scrolling GitHub treding repos I saw &lt;a href=&#34;https://github.com/sinaatalay/rendercv&#34;&gt;RenderCV&lt;/a&gt; which let&amp;rsquo;s me just use YAML to write my resume and then it compiles to Tek through Python. There&amp;rsquo;s a sister project to make your own using this very easly call &lt;a href=&#34;https://github.com/sinaatalay/rendercv-pipeline&#34;&gt;rendercv-pipeline&lt;/a&gt;. I forked that repo and translated my tek resume to the YAML. The included theme is nice enough is YAML is much easier to maintain long-term.&lt;/p&gt;&#xA;&lt;p&gt;My resume is behind a private GH repo but the example from rendercv-pipeline is &lt;a href=&#34;https://github.com/sinaatalay/rendercv-pipeline/blob/main/John_Doe_CV.pdf&#34;&gt;here on GitHub&lt;/a&gt;&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Modal Labs</title>
    <id>https://pype.dev/modal-labs/</id>
    <updated>2022-12-28T21:01:52Z</updated>
    <published>2022-12-28T21:01:52Z</published>
    <link href="https://pype.dev/modal-labs/" rel="alternate" type="text/html"></link>
    <summary type="text">Playing around with Modal Labs</summary>
    <content type="html">&lt;p&gt;Playing around with Modal Labs&lt;/p&gt;&#xA;&lt;p&gt;One of the first things I tried was a regular cron job&amp;hellip;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@stub.function&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;schedule&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;modal&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Period&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;minutes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;59&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;secret&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;modal&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Secret&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;from_name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;my-dummy-secret&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;say_hi&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;now&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;time&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ctime&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;secret&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;os&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;environ&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;dummy-secret&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sa&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Hello &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;os&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;environ&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;USER&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Rodney&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt; at &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;now&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sa&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;secret&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;=}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This can get deployed with &lt;code&gt;modal deploy --name &amp;lt;app name&amp;gt; &amp;lt;path to .py file with the stub and function defined in it&amp;gt; &lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This function gets deployed as an app that I conveniently call &lt;code&gt;say_hi&lt;/code&gt; (as far&#xA;as I can tell the app name can be anything - as I add functions to this same&#xA;app and deploy with the same name to get a new version)&lt;/p&gt;&#xA;&lt;p&gt;Notice that this also is an example of giving access to a secret - defined in the Modal Labs dashboard&lt;/p&gt;&#xA;&lt;p&gt;We can take a look at the apps running at &lt;a href=&#34;https://modal.com/apps&#34;&gt;https://modal.com/apps&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I then added another function to experiment with custom container images and&#xA;saw then that Modal will just slap a new version on anything provisioned with&#xA;the same name (intuitive enough for sure) so when I add functions to my .py&#xA;script and run &lt;code&gt;modal deploy --name say_hi myscript.py&lt;/code&gt; over and over, the app&#xA;called &lt;code&gt;say_hi&lt;/code&gt; in the Modal apps dashboard just gets a new version&lt;/p&gt;&#xA;&lt;p&gt;This means I can spin up several instances of functionally the same app but with different names/versions etc&amp;hellip;&#xA;Q: Maybe there&amp;rsquo;s gitops or policy stuff builtin to app names then?&lt;/p&gt;&#xA;&lt;p&gt;I needed to take down an app I deployed as a duplicate but you don&amp;rsquo;t stop apps&#xA;by name, you stop them by an id&amp;hellip; see below&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;modal-sandbox/modal_sandbox   main   ×1  ×9 via   v3.10.6(modal-sandbox)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;✗ modal app stop --help&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt; Usage: modal app stop [OPTIONS] APP_ID&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt; Stop an app.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ *    app_id      TEXT  [default: None] [required]                                                                                                │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ --help          Show this message and exit.                                                                                                      │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;modal-sandbox/modal_sandbox   main   ×1  ×9 via   v3.10.6(modal-sandbox)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;❯ modal app list&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;┃ App ID                    ┃ Description         ┃ State    ┃ Creation time             ┃ Stop time                 ┃&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ ap-lzy1AAuVy7POFkUcDKRxpQ │ print_info          │ deployed │ 2022-12-28 20:59:07-06:00 │                           │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ ap-qYjE45dciqgT3C3CpNp3RL │ say_hi              │ deployed │ 2022-12-28 19:49:22-06:00 │                           │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ ap-X7FYneUeYV5IKHcyirSb87 │ link-scraper        │ stopped  │ 2022-12-28 15:39:02-06:00 │ 2022-12-28 15:39:04-06:00 │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;│ ap-UOXTUU4uSRx2UZypJOcAsk │ example-get-started │ stopped  │ 2022-12-28 15:17:47-06:00 │ 2022-12-28 15:17:49-06:00 │&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;└───────────────────────────┴─────────────────────┴──────────┴───────────────────────────┴───────────────────────────┘&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;modal-sandbox/modal_sandbox   main   ×1  ×9 via   v3.10.6(modal-sandbox)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;go&#34;&gt;❯ modal app stop ap-lzy1AAuVy7POFkUcDKRxpQ&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;git-warning&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Git warning!&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I ran &lt;code&gt;modal deploy ...&lt;/code&gt; after comitting some stuff I wanted to try BUT I had&#xA;changes in my file I didn&amp;rsquo;t want to deploy&amp;hellip; some git safety would be nice for&#xA;deployment!&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;git stash &amp;amp;&amp;amp; modal deploy .. &amp;amp;&amp;amp; git stash pop&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Question for Modal team - in my modal sandbox repo at commit:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;aab6162 (HEAD -&amp;gt; main) HEAD@{1}: commit: print base version of my own image to prove it to me&#xA; 1 file changed, 2 insertions(+)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An environment variable, &lt;code&gt;BASE_VERSION&lt;/code&gt; that I expect to be in my base image&#xA;was not available to the python function in my Modal app&amp;hellip; hopefully the log&#xA;is still&#xA;&lt;a href=&#34;https://modal.com/logs/ap-qYjE45dciqgT3C3CpNp3RL?functionId=fu-rOt31ShRE1W1CQfuf02fsq&amp;amp;taskId=ta-dm8BfiblvFLwVIQyt75YC2&amp;amp;inputId=in-n64klEFrLtbcm2BiykJEvW&#34;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;github-actions&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;GitHub Actions&lt;/span&gt; &lt;a href=&#34;#github-actions&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I think it&amp;rsquo;d be easy to deploy from GH actions&amp;hellip; just need an API Key&amp;hellip;&lt;/p&gt;&#xA;&lt;h1 id=&#34;deployment&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Deployment&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Without gitops it&amp;rsquo;s already ahrd to manage my versions&amp;hellip; need to get that built in either to github or locally sooooon&lt;/p&gt;&#xA;&lt;p&gt;Nomad?? :D&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Call basicConfig to get Python log messages in iPython</title>
    <id>https://pype.dev/call-basicconfig-to-get-python-log-messages-in-ipython/</id>
    <updated>2022-12-10T14:04:23Z</updated>
    <published>2022-12-10T14:04:23Z</published>
    <link href="https://pype.dev/call-basicconfig-to-get-python-log-messages-in-ipython/" rel="alternate" type="text/html"></link>
    <summary type="text">I am trying to adopt instead of but ran into a confusing thing in ipython during Advent of Code... I riddled by script with (yes after setting ) but in...</summary>
    <content type="html">&lt;h1 id=&#34;logging-instead-of-printing&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Logging instead of printing&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I am trying to adopt &lt;code&gt;logger.debug&lt;/code&gt; instead of &lt;code&gt;print&lt;/code&gt; but ran into a confusing&#xA;thing in ipython during Advent of Code&amp;hellip; I riddled by script with&#xA;&lt;code&gt;logger.debug&lt;/code&gt; (yes after setting &lt;code&gt;logging.setLevel(&#39;DEBUG&#39;)&lt;/code&gt;) but in ipython&#xA;none of my log messages showed up!&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;logging&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;logger&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;logging&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getLogger&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;vm&#34;&gt;__name__&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;logger&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setLevel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;DEBUG&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Turns out what I was missing was a call to &lt;code&gt;basicConfig&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;logging&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# forget this and your messages are in the ether! or at least not seen in ipython...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;logging&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;basicConfig&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;logger&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;logging&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getLogger&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;vm&#34;&gt;__name__&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;logger&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setLevel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;DEBUG&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;bonus&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Bonus&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Want your new messages to show up while iterating on something without killing&#xA;the ipython kernel?&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;importlib&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;reload&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;reload&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;logging&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;# to make sure you get new log messages you add while developing!&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Benchmark your disks with fio</title>
    <id>https://pype.dev/benchmark-your-disks-with-fio/</id>
    <updated>2022-08-27T13:43:22Z</updated>
    <published>2022-08-27T13:43:22Z</published>
    <link href="https://pype.dev/benchmark-your-disks-with-fio/" rel="alternate" type="text/html"></link>
    <summary type="text">I use ZFS at home in my homelab for basically all of my storage... Docker uses ZFS backend, all my VMs have their images in their own zfs datasets, and all...</summary>
    <content type="html">&lt;h1 id=&#34;intro&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Intro&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I use ZFS at home in my homelab for basically all of my storage&amp;hellip; &lt;a href=&#34;/docker/&#34; class=&#34;glossary-term&#34; title=&#34;docker - container runtime&#34; data-hover-title=&#34;docker&#34;&gt;Docker&lt;/a&gt; uses&#xA;ZFS backend, all my VMs have their &lt;code&gt;.qcow2&lt;/code&gt; images in their own zfs datasets,&#xA;and all my shares are ZFS datasets. I love ZFS but my home hardware presently&#xA;is the opposite of expensive or new&amp;hellip; Thankfully I&amp;rsquo;ve had a lot of my orginal&#xA;homelab simply given to me but the cost of this is that I didn&amp;rsquo;t put my&#xA;machines together, I didn&amp;rsquo;t choose the disks, and I definitely didn&amp;rsquo;t do the&#xA;research I would&amp;rsquo;ve otherwise done had I bankrolled my server personally&amp;hellip;&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;The Problem&lt;/span&gt; &lt;a href=&#34;#the-problem&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I run &lt;code&gt;glances&lt;/code&gt; on basically all my machines and for the longest time I have&#xA;been seeing big time &lt;code&gt;iowait&lt;/code&gt; issues. Now, since everything was free I&amp;rsquo;ve&#xA;largely been able to ignore that however I&amp;rsquo;m now after some better performance&#xA;which I think means new hardware!&lt;/p&gt;&#xA;&lt;p&gt;Here is a random screenshot of my glances homepage at time of writing - The&#xA;only major load on my server is some &lt;code&gt;ffmpeg&lt;/code&gt; transcoding (about 60% CPU&#xA;utilization)&amp;hellip;&lt;/p&gt;&#xA;&lt;img src=&#34;https://cdn.statically.io/gh/pypeaday/images.pype.dev/main/blog-media/glances-iowait.png&#34; alt=&#34;glances&#34; title=&#34;glances with iowait&#34; /&gt;&#xA;&lt;p&gt;As you can see&amp;hellip; there&amp;rsquo;s a lot of issues and &lt;em&gt;I don&amp;rsquo;t even know what they mean&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;h1 id=&#34;fio&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;fio&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;I heard about &lt;a href=&#34;https://fio.readthedocs.io/en/latest/&#34;&gt;fio&lt;/a&gt; through a friend and&#xA;decided to try it out quick. It installs with &lt;code&gt;apt&lt;/code&gt; on ubuntu quick and easy&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Jim Saltar has a good blog post on it &lt;a href=&#34;https://arstechnica.com/gadgets/2020/02/how-fast-are-your-disks-find-out-the-open-source-way-with-fio/&#34;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically it&amp;rsquo;s a handy tool for benchmarking your disks and the blog dives into&#xA;what types of metrics matter - it&amp;rsquo;s not just throughput, but also latency,&#xA;iops, etc.&lt;/p&gt;&#xA;&lt;h2 id=&#34;tests&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Tests&lt;/span&gt; &lt;a href=&#34;#tests&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I ran a few basic commands inside a new zfs dataset on my server &lt;code&gt;tank/fio&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;fio --name&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;random-write --ioengine&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;posixaio --rw&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;randwrite --bs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;4k --size&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;4g --numjobs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; --runtime&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;60&lt;/span&gt; --time_based --end_fsync&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; &amp;gt; single-4KiB-random-write.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;fio --name&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;random-write --ioengine&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;posixaio --rw&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;randwrite --bs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;64k --size&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;256m --numjobs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;16&lt;/span&gt; --iodepth&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;16&lt;/span&gt; --runtime&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;60&lt;/span&gt; --time_based --end_fsync&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; &amp;gt; 16-parallel-64KiB-random-write.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;fio --name&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;random-write --ioengine&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;posixaio --rw&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;randwrite --bs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;1m --size&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;16g --numjobs&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; --iodepth&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; --runtime&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;60&lt;/span&gt; --time_based --end_fsync&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; &amp;gt; single-1MiB-random-write.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;results&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Results&lt;/span&gt; &lt;a href=&#34;#results&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The single 4 KiB random write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WRITE: bw=7836KiB/s (8024kB/s), 7836KiB/s-7836KiB/s (8024kB/s-8024kB/s), io=523MiB (548MB), run=68317-68317msec&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The 16 parallel 64KiB random writes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WRITE: bw=93.9MiB/s (98.4MB/s), 5599KiB/s-6303KiB/s (5734kB/s-6454kB/s), io=7642MiB (8013MB), run=81310-81418msec&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The single 1MiB random write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WRITE: bw=81.2MiB/s (85.1MB/s), 81.2MiB/s-81.2MiB/s (85.1MB/s-85.1MB/s), io=8177MiB (8574MB), run=100699-100699msec&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;summary&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Summary&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;So I don&amp;rsquo;t fully understand these numbers yet&amp;hellip; 80-100 MiB/s isn&amp;rsquo;t super fast&#xA;and that&amp;rsquo;s across a parallelized workload&amp;hellip; The single threaded workloads have&#xA;awful performance so this tells me something is wrong&amp;hellip; I have a few ideas&amp;hellip;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;ZFS dataset config options such as &lt;code&gt;ashift&lt;/code&gt; or the blocksize might be way misconfigured&lt;/li&gt;&#xA;&lt;li&gt;The disks/pool which came from a TrueNAS/FreeBSD machine may have some artifacts that I need to clean up&lt;/li&gt;&#xA;&lt;li&gt;The SAS controller I am using, which I flashed with IT firmware to get it into JBOD mode might be messed up&lt;/li&gt;&#xA;&lt;li&gt;The data cables themselves could be a problem&amp;hellip;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Points 3 and 4 are less likely given that the write speed does increase in the parallelized job but I&amp;rsquo;m a newbie so it&amp;rsquo;s time to dive in!&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Playing with mdformat</title>
    <id>https://pype.dev/playing-with-mdformat/</id>
    <updated>2022-08-23T06:56:15Z</updated>
    <published>2022-08-23T06:56:15Z</published>
    <link href="https://pype.dev/playing-with-mdformat/" rel="alternate" type="text/html"></link>
    <content type="html">&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;what is taking so long black!!&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Add colored indicators to your dataframes html representation</title>
    <id>https://pype.dev/add-colored-indicators-to-your-dataframes-html-representation/</id>
    <updated>2022-06-04T06:12:33Z</updated>
    <published>2022-06-04T06:12:33Z</published>
    <link href="https://pype.dev/add-colored-indicators-to-your-dataframes-html-representation/" rel="alternate" type="text/html"></link>
    <summary type="text">Mike Driscoll recently tweeted about making colored out with pandas DataFrames and I just had to try it for myself</summary>
    <content type="html">&lt;p&gt;&lt;a href=&#34;https://twitter.com/driscollis&#34;&gt;Mike Driscoll&lt;/a&gt; recently tweeted about making&#xA;colored out with pandas DataFrames and I just had to try it for myself&lt;/p&gt;&#xA;&lt;h1 id=&#34;use-case&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Use Case&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;First though&amp;hellip; why?&#xA;My biggest use case is a monitoring pipeline of mine&amp;hellip; The details aside, the&#xA;output of my pipeline is a dataframe where each row has information about a&#xA;failed pipeline that I need to go look into. I dump that result to a simle html&#xA;file that&amp;rsquo;s hosted on an internal site and the file is updated every couple of&#xA;hours. Adding some colored indicators automatically to the rows to help me&#xA;assess severity of each record would be a handy way to quickly get an&#xA;understanding the state of our pipelines.&lt;/p&gt;&#xA;&lt;h1 id=&#34;how&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;How?&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;The docs for the &lt;code&gt;applymap&lt;/code&gt; method state simply:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Apply a CSS-styling function elementwise.&#xA;&#xA;Updates the HTML representation with the result.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So we can write a function that returns &lt;code&gt;color: {color}&lt;/code&gt; based on the dataframe&#xA;values and when we drop that dataframe to html we&amp;rsquo;ll have some simple css&#xA;styling applied automagically!&lt;/p&gt;&#xA;&lt;p&gt;By default the function will be applied to all columns of the dataframe, but&#xA;that&amp;rsquo;s not useful if the columns are different types which is usually the case.&#xA;Luckily there is a &lt;code&gt;subset&lt;/code&gt; keyword to only apply to the columns you need!&lt;/p&gt;&#xA;&lt;p&gt;Consider my example&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;n&#34;&gt;main&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;via&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;3.8.11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ipython&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;❯&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;df&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pd&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;read_csv&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;cars.csv&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;n&#34;&gt;main&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;via&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;3.8.11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ipython&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;❯&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;mpg_color&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;val&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;float&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;     &lt;span class=&#34;n&#34;&gt;color&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;val&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;21&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;green&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;     &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;sa&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;color: &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;color&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;n&#34;&gt;main&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;via&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;3.8.11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sandbox&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ipython&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;❯&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;df&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;style&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;applymap&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;mpg_color&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;subset&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;mpg&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;to_html&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;color.html&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I want to quickly see if the &lt;code&gt;mpg&lt;/code&gt; is any good for the cars in the cars dataset&#xA;and I&amp;rsquo;ll define &amp;ldquo;good&amp;rdquo; as better than 21 mpg (not great I know but just for the&#xA;sake of discussion&amp;hellip;)&lt;/p&gt;&#xA;&lt;p&gt;The function returns an appropriate css string and after I &lt;code&gt;style.applymap&lt;/code&gt; on just the &lt;code&gt;mpg&lt;/code&gt; column we get this!&lt;/p&gt;&#xA;&lt;style type=&#34;text/css&#34;&gt;&#xA;#T_95e99_row0_col1, #T_95e99_row1_col1, #T_95e99_row2_col1, #T_95e99_row3_col1 {&#xA;  color: green;&#xA;}&#xA;#T_95e99_row4_col1 {&#xA;  color: red;&#xA;}&#xA;&lt;/style&gt;&#xA;&lt;table id=&#34;T_95e99&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th class=&#34;blank level0&#34; &gt;&amp;nbsp;&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col0&#34; class=&#34;col_heading level0 col0&#34; &gt;Unnamed: 0&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col1&#34; class=&#34;col_heading level0 col1&#34; &gt;mpg&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col2&#34; class=&#34;col_heading level0 col2&#34; &gt;cyl&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col3&#34; class=&#34;col_heading level0 col3&#34; &gt;disp&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col4&#34; class=&#34;col_heading level0 col4&#34; &gt;hp&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col5&#34; class=&#34;col_heading level0 col5&#34; &gt;drat&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col6&#34; class=&#34;col_heading level0 col6&#34; &gt;wt&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col7&#34; class=&#34;col_heading level0 col7&#34; &gt;qsec&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col8&#34; class=&#34;col_heading level0 col8&#34; &gt;vs&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col9&#34; class=&#34;col_heading level0 col9&#34; &gt;am&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col10&#34; class=&#34;col_heading level0 col10&#34; &gt;gear&lt;/th&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_col11&#34; class=&#34;col_heading level0 col11&#34; &gt;carb&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_row0&#34; class=&#34;row_heading level0 row0&#34; &gt;0&lt;/th&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col0&#34; class=&#34;data row0 col0&#34; &gt;Mazda RX4&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col1&#34; class=&#34;data row0 col1&#34; &gt;21.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col2&#34; class=&#34;data row0 col2&#34; &gt;6&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col3&#34; class=&#34;data row0 col3&#34; &gt;160.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col4&#34; class=&#34;data row0 col4&#34; &gt;110&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col5&#34; class=&#34;data row0 col5&#34; &gt;3.900000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col6&#34; class=&#34;data row0 col6&#34; &gt;2.620000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col7&#34; class=&#34;data row0 col7&#34; &gt;16.460000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col8&#34; class=&#34;data row0 col8&#34; &gt;0&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col9&#34; class=&#34;data row0 col9&#34; &gt;1&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col10&#34; class=&#34;data row0 col10&#34; &gt;4&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row0_col11&#34; class=&#34;data row0 col11&#34; &gt;4&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_row1&#34; class=&#34;row_heading level0 row1&#34; &gt;1&lt;/th&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col0&#34; class=&#34;data row1 col0&#34; &gt;Mazda RX4 Wag&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col1&#34; class=&#34;data row1 col1&#34; &gt;21.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col2&#34; class=&#34;data row1 col2&#34; &gt;6&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col3&#34; class=&#34;data row1 col3&#34; &gt;160.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col4&#34; class=&#34;data row1 col4&#34; &gt;110&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col5&#34; class=&#34;data row1 col5&#34; &gt;3.900000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col6&#34; class=&#34;data row1 col6&#34; &gt;2.875000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col7&#34; class=&#34;data row1 col7&#34; &gt;17.020000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col8&#34; class=&#34;data row1 col8&#34; &gt;0&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col9&#34; class=&#34;data row1 col9&#34; &gt;1&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col10&#34; class=&#34;data row1 col10&#34; &gt;4&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row1_col11&#34; class=&#34;data row1 col11&#34; &gt;4&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_row2&#34; class=&#34;row_heading level0 row2&#34; &gt;2&lt;/th&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col0&#34; class=&#34;data row2 col0&#34; &gt;Datsun 710&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col1&#34; class=&#34;data row2 col1&#34; &gt;22.800000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col2&#34; class=&#34;data row2 col2&#34; &gt;4&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col3&#34; class=&#34;data row2 col3&#34; &gt;108.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col4&#34; class=&#34;data row2 col4&#34; &gt;93&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col5&#34; class=&#34;data row2 col5&#34; &gt;3.850000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col6&#34; class=&#34;data row2 col6&#34; &gt;2.320000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col7&#34; class=&#34;data row2 col7&#34; &gt;18.610000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col8&#34; class=&#34;data row2 col8&#34; &gt;1&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col9&#34; class=&#34;data row2 col9&#34; &gt;1&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col10&#34; class=&#34;data row2 col10&#34; &gt;4&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row2_col11&#34; class=&#34;data row2 col11&#34; &gt;1&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_row3&#34; class=&#34;row_heading level0 row3&#34; &gt;3&lt;/th&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col0&#34; class=&#34;data row3 col0&#34; &gt;Hornet 4 Drive&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col1&#34; class=&#34;data row3 col1&#34; &gt;21.400000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col2&#34; class=&#34;data row3 col2&#34; &gt;6&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col3&#34; class=&#34;data row3 col3&#34; &gt;258.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col4&#34; class=&#34;data row3 col4&#34; &gt;110&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col5&#34; class=&#34;data row3 col5&#34; &gt;3.080000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col6&#34; class=&#34;data row3 col6&#34; &gt;3.215000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col7&#34; class=&#34;data row3 col7&#34; &gt;19.440000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col8&#34; class=&#34;data row3 col8&#34; &gt;1&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col9&#34; class=&#34;data row3 col9&#34; &gt;0&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col10&#34; class=&#34;data row3 col10&#34; &gt;3&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row3_col11&#34; class=&#34;data row3 col11&#34; &gt;1&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th id=&#34;T_95e99_level0_row4&#34; class=&#34;row_heading level0 row4&#34; &gt;4&lt;/th&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col0&#34; class=&#34;data row4 col0&#34; &gt;Hornet Sportabout&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col1&#34; class=&#34;data row4 col1&#34; &gt;18.700000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col2&#34; class=&#34;data row4 col2&#34; &gt;8&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col3&#34; class=&#34;data row4 col3&#34; &gt;360.000000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col4&#34; class=&#34;data row4 col4&#34; &gt;175&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col5&#34; class=&#34;data row4 col5&#34; &gt;3.150000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col6&#34; class=&#34;data row4 col6&#34; &gt;3.440000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col7&#34; class=&#34;data row4 col7&#34; &gt;17.020000&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col8&#34; class=&#34;data row4 col8&#34; &gt;0&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col9&#34; class=&#34;data row4 col9&#34; &gt;0&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col10&#34; class=&#34;data row4 col10&#34; &gt;3&lt;/td&gt;&#xA;      &lt;td id=&#34;T_95e99_row4_col11&#34; class=&#34;data row4 col11&#34; &gt;2&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Subset a list based on values in another list with itertools.compress</title>
    <id>https://pype.dev/subset-a-list-based-on-values-in-another-list-with-itertools-compress/</id>
    <updated>2022-05-19T14:22:58Z</updated>
    <published>2022-05-19T14:22:58Z</published>
    <link href="https://pype.dev/subset-a-list-based-on-values-in-another-list-with-itertools-compress/" rel="alternate" type="text/html"></link>
    <summary type="text">I have list [True, False, False, True] and another list [1, 2, 3, 4] and a use case where I want to filter list 2 based on list 1 to remove values that line...</summary>
    <content type="html">&lt;p&gt;I have list [True, False, False, True] and another list [1, 2, 3, 4] and a use&#xA;case where I want to filter list 2 based on list 1 to remove values that line&#xA;up with the element False in list 1&amp;hellip;. so the outcome will be [1, 4].&#xA;list(compress(list2, list1)) will do it. As long as you can create a mask for&#xA;the filter than itertool.compress will be your friend!&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Forms with FastAPI and Jinja</title>
    <id>https://pype.dev/fastapi-jinja-forms/</id>
    <updated>2022-05-15T00:00:00Z</updated>
    <published>2022-05-15T00:00:00Z</published>
    <link href="https://pype.dev/fastapi-jinja-forms/" rel="alternate" type="text/html"></link>
    <summary type="text">I just started using FastAPI for a home project and needed to pass back a dynamic number of values from a form rendered with jinja...</summary>
    <content type="html">&lt;p&gt;I just started using FastAPI for a home project and needed to pass back a&#xA;dynamic number of values from a form rendered with jinja&amp;hellip;&lt;/p&gt;&#xA;&lt;h1 id=&#34;dynamic-values&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Dynamic Values&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;The jinja templating for rendering HTML based on something like a python iterable is nice and easy&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;data is the result of a database query, and item is each row, so the dot notation is the value of each column basically in that row&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;form method=&amp;#34;post&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{%&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;%}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;div class=&amp;#34;form-check &amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;input class=&amp;#34;form-check-input&amp;#34;  name=&amp;#34;item_&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; id=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.name&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; value=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; type=&amp;#34;checkbox&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;label class=&amp;#34;form-check-label&amp;#34; for=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; &amp;gt; Label for: &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.name&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt; &amp;lt;/label&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;/div&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{%&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;endfor&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;%}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;button type=&amp;#34;submit&amp;#34; class=&amp;#34;submit btn btn-xl btn-outline-danger&amp;#34; &amp;gt;Remove&amp;lt;/button&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;/form&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This form generates a row with a checkbox for every &lt;code&gt;item&lt;/code&gt; in &lt;code&gt;data&lt;/code&gt; (in my&#xA;case each &lt;code&gt;item&lt;/code&gt; is an existing row in my table). it?&lt;/p&gt;&#xA;&lt;p&gt;The way to pass back all those values is pretty straight forward (after hours of messing around that is!)&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# I hate it when tutorials don&amp;#39;t show ALL relevant pieces to the blurb&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;starlette.status&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;status&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;APIRouter&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Depends&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Request&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.encoders&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;jsonable_encoder&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.responses&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RedirectResponse&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.templating&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Jinja2Templates&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;sqlalchemy.orm&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Session&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;app.session.session&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;create_get_session&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;router&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;APIRouter&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;templates&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Jinja2Templates&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;directory&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;templates/&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@router.post&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/my_route/do_something_with_form&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;response_class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;delete_rows&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;db&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Session&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Depends&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;create_get_session&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;form_data&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;await&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;get_form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;jsonable_encoder&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;form_data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# data = {&amp;#34;item_1&amp;#34;: 1, &amp;#34;item_2&amp;#34;: 2, ... &amp;#34;item_N&amp;#34;: N}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RedirectResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;status_code&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;status&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTTP_302_FOUND&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We &lt;code&gt;await request.get_form()&lt;/code&gt; and after encoding the data we get a dictionary with key/value pairs of the name/value from the form!&lt;/p&gt;&#xA;&lt;p&gt;This took me quite a long time to figure out in part because most of the Google-able resources are still on Flask&amp;hellip;&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Dynamic-Form-Values-With-Jinja-And-Fastapi</title>
    <id>https://pype.dev/dynamic-form-values-with-jinja-and-fastapi/</id>
    <updated>2022-05-15T00:00:00Z</updated>
    <published>2022-05-15T00:00:00Z</published>
    <link href="https://pype.dev/dynamic-form-values-with-jinja-and-fastapi/" rel="alternate" type="text/html"></link>
    <summary type="text">I&#39;m currently working on a self-hostable wish list app using FastAPI so we can finally drop Amazon forever. (The lists funcionality has been super handy for...</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;m currently working on a self-hostable wish list app using FastAPI so we can&#xA;finally drop Amazon forever. (The lists funcionality has been super handy for&#xA;sharing holiday gift ideas with the famj!)&lt;/p&gt;&#xA;&lt;h1 id=&#34;fastapi&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;FastAPI&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;FastAPI is an amazing framework for quickly building APIs with Python. I will have a slightly longer post about my brief experience with it coming later&amp;hellip;&lt;/p&gt;&#xA;&lt;h1 id=&#34;jinja-forms-and-fastapi&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Jinja, Forms, and FastAPI&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;One of the last things I needed to figure out in my app was how to generate a&#xA;form in a Jinja template with a dynamic number of inputs and then pass all the&#xA;inputs to the backend to perform a database operation (my exact case was&#xA;removing rows from a table).&lt;/p&gt;&#xA;&lt;h2 id=&#34;explicit-values&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Explicit Values&lt;/span&gt; &lt;a href=&#34;#explicit-values&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The way to pass back explicit variables is really easy&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Our form would look like this (I&amp;rsquo;m using bootstrap CSS)&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;form method=&amp;#34;post&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;div class=&amp;#34;form-check &amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;input class=&amp;#34;form-check-input&amp;#34;  name=&amp;#34;item_1&amp;#34; id=&amp;#34;itemOne&amp;#34; value=&amp;#34;1&amp;#34; type=&amp;#34;checkbox&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;label class=&amp;#34;form-check-label&amp;#34; for=&amp;#34;itemOne&amp;#34; &amp;gt; A label for this item &amp;lt;/label&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;/div&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;div class=&amp;#34;form-check &amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;input class=&amp;#34;form-check-input&amp;#34;  name=&amp;#34;item_2&amp;#34; id=&amp;#34;itemTwo&amp;#34; value=&amp;#34;2&amp;#34; type=&amp;#34;checkbox&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;label class=&amp;#34;form-check-label&amp;#34; for=&amp;#34;itemTwo&amp;#34; &amp;gt; A label for item 2 &amp;lt;/label&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;/div&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;button type=&amp;#34;submit&amp;#34; class=&amp;#34;submit btn btn-xl&amp;#34; &amp;gt;Submit&amp;lt;/button&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;/form&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So what is this? This form will have 2 rows with the lables you see in &lt;code&gt;&amp;lt;label&amp;gt; &amp;lt;/label&amp;gt;&lt;/code&gt; and checkboxes that when checked would have the value &lt;code&gt;value&lt;/code&gt; in each&#xA;&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; line.&lt;/p&gt;&#xA;&lt;p&gt;So our backend might looks something like this&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I&amp;rsquo;m keeping all the imports and stuff here to show where they come from but I won&amp;rsquo;t discuss it all here - that&amp;rsquo;ll be in a future post&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;starlette.status&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;status&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;APIRouter&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Depends&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Request&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.encoders&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;jsonable_encoder&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.responses&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RedirectResponse&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;fastapi.templating&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Jinja2Templates&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;sqlalchemy.orm&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Session&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;app.session.session&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;create_get_session&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;router&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;APIRouter&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;templates&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Jinja2Templates&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;directory&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;templates/&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@router.post&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/my_route/do_something_with_form&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;response_class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;delete_rows&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;item_1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;item_2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;db&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Session&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Depends&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;create_get_session&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item_1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;# will just print 1 to the console where fastapi is running if the checkbox was checked&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item_2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;# will just print 1 to the console where fastapi is running if the checkbox was checked&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RedirectResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;status_code&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;status&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTTP_302_FOUND&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;dynamic-values&#34;&gt;&lt;span class=&#34;heading-wear-glyph&#34;&gt;Dynamic values&lt;/span&gt; &lt;a href=&#34;#dynamic-values&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;That&amp;rsquo;s all pretty simple&amp;hellip; pass back values by the name in the form&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;What about a form that&amp;rsquo;s generated dynamically? This is my case since I display a row/checkbox for every row in my table so my form looks like this&amp;hellip;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;data is the result of a database query, and item is each row, so the dot notation is the value of each column basically in that row&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;form method=&amp;#34;post&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{%&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;%}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;div class=&amp;#34;form-check &amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;input class=&amp;#34;form-check-input&amp;#34;  name=&amp;#34;item_&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; id=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.name&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; value=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; type=&amp;#34;checkbox&amp;#34;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;        &amp;lt;label class=&amp;#34;form-check-label&amp;#34; for=&amp;#34;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.id&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&amp;#34; &amp;gt; Label for: &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;item.name&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt; &amp;lt;/label&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;    &amp;lt;/div&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;{%&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;endfor&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;%}&lt;/span&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;button type=&amp;#34;submit&amp;#34; class=&amp;#34;submit btn btn-xl btn-outline-danger&amp;#34; &amp;gt;Remove&amp;lt;/button&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&amp;lt;/form&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;x&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This form generates a row with a checkbox for every &lt;code&gt;item&lt;/code&gt; in &lt;code&gt;data&lt;/code&gt; (in my&#xA;case each &lt;code&gt;item&lt;/code&gt; is an existing row in my table). Now I started scratching my&#xA;head on how to pass an unknown number of inputs to my backend of FastAPI wants&#xA;each input explicitly defined and typed&amp;hellip; I can&amp;rsquo;t just pass the form back&#xA;becuase that&amp;rsquo;s not a thing so what&amp;rsquo;s the way to do it?&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# same stuff as above, only showing post method here&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@router.post&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/my_route/do_something_with_form&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;response_class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTMLResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;delete_rows&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;db&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Session&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Depends&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;create_get_session&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;form_data&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;await&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;request&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;get_form&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;jsonable_encoder&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;form_data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# data = {&amp;#34;item_1&amp;#34;: 1, &amp;#34;item_2&amp;#34;: 2, ... &amp;#34;item_N&amp;#34;: N}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RedirectResponse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;status_code&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;status&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;HTTP_302_FOUND&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We &lt;code&gt;await request.get_form()&lt;/code&gt; and after encoding the data we get a dictionary with key/value pairs of the name/value from the form!&lt;/p&gt;&#xA;&lt;p&gt;This took me quite a long time to figure out in part because most of the Google-able resources are still on Flask&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;I look forward to my wish list app maturing and I hope this helps someone working with FastAPI!&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
</feed>