<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mwchase</title>
    <description>The latest articles on DEV Community by mwchase (@mwchase).</description>
    <link>https://dev.to/mwchase</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F475937%2Fa0c4b383-0c76-4c6f-8430-7cb52c9a0980.png</url>
      <title>DEV Community: mwchase</title>
      <link>https://dev.to/mwchase</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mwchase"/>
    <language>en</language>
    <item>
      <title>Looking Beyond Nox</title>
      <dc:creator>mwchase</dc:creator>
      <pubDate>Fri, 09 Apr 2021 00:50:33 +0000</pubDate>
      <link>https://dev.to/mwchase/looking-beyond-nox-1h5g</link>
      <guid>https://dev.to/mwchase/looking-beyond-nox-1h5g</guid>
      <description>&lt;p&gt;I've gone through what I assume is a fairly typical journey between different ways to run tasks related to a Python project: from hand-rolled shell and Python scripts, to &lt;a href="https://tox.readthedocs.io/"&gt;tox&lt;/a&gt;, to &lt;a href="https://nox.thea.codes/"&gt;Nox&lt;/a&gt;. To be honest, I'm not sure how many people have switched from tox to Nox, but now that I've used Nox, I don't ever want to edit a tox.ini file again.&lt;/p&gt;

&lt;p&gt;All that said, I think I'm starting to push past what is reasonable to do with Nox.&lt;/p&gt;

&lt;p&gt;In one of my private hobby projects, I have a single host repo that has (currently) five package directories nested inside it. I've got a noxfile set up that will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prepare for the &lt;a href="https://coverage.readthedocs.io/"&gt;coverage&lt;/a&gt; runs by deleting the previous coverage data.&lt;/li&gt;
&lt;li&gt;Run syntax checks, including &lt;a href="https://pycqa.github.io/isort/"&gt;isort&lt;/a&gt; through &lt;a href="https://flake8.pycqa.org/"&gt;flake8&lt;/a&gt;, and generate a report for each sub-project.&lt;/li&gt;
&lt;li&gt;Run &lt;a href="http://mypy-lang.org/"&gt;Mypy&lt;/a&gt; against each project, generating coverage (in html) and error (in junit xml) reports.&lt;/li&gt;
&lt;li&gt;Run &lt;a href="https://docs.pytest.org/"&gt;pytest&lt;/a&gt; against each project, generating a junit xml report.&lt;/li&gt;
&lt;li&gt;Run pytest, under coverage, and generate a coverage data file for each project, in addition to a separate junit xml report.&lt;/li&gt;
&lt;li&gt;Run pytest, under &lt;a href="https://github.com/joerick/pyinstrument"&gt;pyinstrument&lt;/a&gt;, and generate a webpage that presents performance data, in addition to a separate junit xml report.&lt;/li&gt;
&lt;li&gt;Merge the junit results from each kind of pytest run, creating three merged junit files, each containing data from all of the sub-projects.&lt;/li&gt;
&lt;li&gt;Convert the various junit xml reports to html via &lt;a href="https://gitlab.com/inorton/junit2html"&gt;junit2html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Merge the per-project coverage files into one&lt;/li&gt;
&lt;li&gt;(Currently disabled) winnow down the coverage report to ignore certain coverage contexts that I have decided "shouldn't count". (This is implemented through a package I wrote that, while public, is probably not ready for general use, even among people who want what it provides.)&lt;/li&gt;
&lt;li&gt;Generate an HTML report of the coverage.&lt;/li&gt;
&lt;li&gt;Report if the coverage metric is below a defined threshold.&lt;/li&gt;
&lt;li&gt;Build executable python archives for each endpoint defined by a project, using &lt;a href="https://shiv.readthedocs.io/"&gt;shiv&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is... a lot, but my hobby code tends not to do much I/O, so, just for the sake of my own curiosity, let's do a &lt;code&gt;time nox&lt;/code&gt;. Running that while writing this post and having YouTube playing in the background gets me an execution time of... not instant... Long enough that I should probably tab away from this text box...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;________________________________________________________
Executed in  295.79 secs    fish           external
   usr time  251.25 secs  494.00 micros  251.25 secs
   sys time   29.97 secs  154.00 micros   29.97 secs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Oof. So, you can see why I'd be interested in shaving time off of this.&lt;/p&gt;

&lt;p&gt;There are currently GitHub issues against Nox for adding parallelism, but I'm not sure if they're going anywhere, and they're prioritizing stuff like "having legible input when you're running multiple commands at once", which is a non-issue for me; due to the large volume of data that Nox was already generating, I rewrote my sessions to direct all relevant output into webpages. Now, I just need to read the summary at the end to see which commands had a non-zero exit code, and I can open my web browser to see the data produced by subsequent commands acting on the output of the failed command.&lt;/p&gt;

&lt;p&gt;(Remember that last sentence, it's important!)&lt;/p&gt;

&lt;p&gt;So, if I want to port all of this to a tool that can figure out &lt;em&gt;which&lt;/em&gt; things to run in parallel, and &lt;em&gt;run them&lt;/em&gt;, what are my options?&lt;/p&gt;

&lt;p&gt;I've mostly been looking at Python-based stuff, but I'm willing to go in all kinds of directions. Here are my general requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parallel execution&lt;/li&gt;
&lt;li&gt;Feasible to work with Python virtualenvs&lt;/li&gt;
&lt;li&gt;Possible to specify that specific commands should allow execution to continue if they exit with a specific non-zero exit code, but be called out as failing in the final summary. (This code is &lt;em&gt;usually&lt;/em&gt; 1, but it's 2 for &lt;code&gt;coverage report&lt;/code&gt;, so I need to be able to specify this per-command.)&lt;/li&gt;
&lt;li&gt;Any incremental build features can handle conditions like "something changed in subproject A that is a dependency of subproject B, so &lt;em&gt;both&lt;/em&gt; A and B need to rerun everything (except flake8 against B, I guess)". ("No incremental build features" would entirely satisfy this requirement.)&lt;/li&gt;
&lt;li&gt;A nice-to-have would be that &lt;code&gt;ctrl-c&lt;/code&gt; propagates into the processes and interrupts them instead of just stop execution outright. I don't know how feasible/widespread this is, I just know that &lt;code&gt;drone exec&lt;/code&gt; &lt;em&gt;doesn't&lt;/em&gt; do this, and seemingly isn't planned to.&lt;/li&gt;
&lt;li&gt;The tool should not assume the use of a specific VCS, because I'm not using any of the popular ones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've looked at a few different projects that handle parallel execution, and I haven't found anything &lt;em&gt;saying&lt;/em&gt; that any of them support the third feature given above, and I'm not sure I'd trust any to handle the fourth, without testing it myself.&lt;/p&gt;

&lt;p&gt;So far, I've looked, relatively superficially, at &lt;a href="https://ninja-build.org/"&gt;Ninja&lt;/a&gt;, &lt;a href="https://pydoit.org/"&gt;doit&lt;/a&gt;, &lt;a href="https://bazel.build/"&gt;Bazel&lt;/a&gt;, and &lt;a href="https://scons.org/"&gt;SCons&lt;/a&gt;.&lt;br&gt;
It looks to me like Ninja and doit won't handle the third point above without requiring something really strange, and if Bazel or SCons documents things one way or the other, I haven't found it yet.&lt;/p&gt;

&lt;p&gt;So, are any of those tools a better fit than I realize? Are there other tools you'd recommend?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>taskrunner</category>
      <category>python</category>
    </item>
  </channel>
</rss>
