<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paul Billing-Ross on Medium]]></title>
        <description><![CDATA[Stories by Paul Billing-Ross on Medium]]></description>
        <link>https://medium.com/@pbilling_97992?source=rss-5f1121fc246------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OsCySD9NbtOuK1rqvaZFdw.png</url>
            <title>Stories by Paul Billing-Ross on Medium</title>
            <link>https://medium.com/@pbilling_97992?source=rss-5f1121fc246------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:36:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pbilling_97992/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Send your bioinformatics sky high]]></title>
            <link>https://medium.com/@pbilling_97992/send-your-bioinformatics-sky-high-389f0cfe6efd?source=rss-5f1121fc246------2</link>
            <guid isPermaLink="false">https://medium.com/p/389f0cfe6efd</guid>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Paul Billing-Ross]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 13:02:27 GMT</pubDate>
            <atom:updated>2023-01-20T13:02:27.636Z</atom:updated>
            <content:encoded><![CDATA[<p>5 tips for doing reproducible analyses in the cloud</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0EPUM7xKv9hTJveXgQ4oqQ.png" /><figcaption>“A space themed Cosmopolitan magazine cover” courtesy of DALL·E</figcaption></figure><ol><li><strong>Move compute to the data, not the other way around.</strong> If you are dealing with data big enough to use cloud, storage is a big money sink. Avoid duplicating data as much as possible by doing your analyses wherever your data lives. Moving data around also makes it more difficult to track data provenance, or lineage, which is essential for reproducing analyses.</li><li><strong>Do everything on the cloud.</strong> Not some on cloud and then some on your local machine where you already have all your Python/R packages configured. Everything on cloud all the time. Why?<br>- <strong>Reproducibility</strong>: You knew it was coming. I think I’ve shown great restraint by not putting it in the first point <em>(Editor’s note: </em>he did<em>)</em>. Your local computing environment is not reproducible. Don’t fall into the trap of thinking that because you use a Python virtual environment your local computer is a reproducible environment. Python virtual environments come from the same people who brought you pip, a whole other separate software you have to use to install Python packages. You are going to trust those people? Furthermore, your local environment <em>is disgusting</em>. Close your tabs.<br>- <strong>Monitoring:</strong> With tools like <a href="https://cloud.google.com/monitoring">Cloud Monitoring</a>, you can track and query resource usage and costs at a granular level, generating data you can use to predict costs/usage for future analyses.<br>- <strong>Security:</strong> We’ve already established the degeneracy of your local computing behavior. Stay on cloud where a trained professional (or at least, someone else) can set firewall rules, data access parameters, monitor network traffic, etc. At the least, you’ll only share responsibility for security failures. If you put data on your laptop and someone steals it, that’s all you.</li><li><strong>Code your analyses in computational notebooks.</strong> Reproducibility and replicability. Nobody reads papers, so put the description of your methods right next to your code and include every step as code. Then put the results next to that so the reader has all the relevant information in one place and <a href="https://quarto.org/">publish it on the internet</a>. And then, don’t bother writing a “paper”. Why are you writing a paper? You want to be a professor? Those jobs don’t exist. You want to write grants for the rest of your life? Grow up.</li><li><strong>Track everything in version control.</strong> There’s nothing cloud specific about this one. If it’s not in version control, it’s ephemeral and can disappear at any time, like a butterfly swept away on a particularly strong gust of wind. Also, nobody else can see it or comment on it or point out the mistakes you made before you present your wrong and bad findings. I use Git (software) &amp; GitHub (provider) for version control. There are other providers and (technically) other softwares, if you are interested.</li><li><strong>Don’t do anything manually. </strong><em>Re</em>proDEUCE<em>abilly</em>Tay. REPRODUCIBILITY. If you can program a computer to do it, it’s probably still not reproducible (knowing you). If you can’t program a computer to do it, it’s definitely not reproducible. It might as well have never happened.</li></ol><p>If these tips aren’t enough for you, here’s some further reading, you sexy nerds.</p><ul><li><a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005994">Eleven quick tips for architecting biomedical informatics workflows with cloud computing</a></li><li><a href="https://www.nature.com/articles/d41586-022-00563-z">Cut the tyranny of copy-and-paste with these coding tools</a></li><li><a href="https://www.nature.com/articles/d41586-018-07196-1">Why Jupyter is data scientists’ computational notebook of choice</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=389f0cfe6efd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sustaining bioinformatics infrastructure: lessons from PBOT]]></title>
            <link>https://medium.com/@pbilling_97992/sustaining-bioinformatics-infrastructure-lessons-from-pbot-fc13c0ff1893?source=rss-5f1121fc246------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc13c0ff1893</guid>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Paul Billing-Ross]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 13:01:47 GMT</pubDate>
            <atom:updated>2023-01-13T13:01:47.419Z</atom:updated>
            <content:encoded><![CDATA[<p>What the challenges of physical systems can teach us about digital ones</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8HJXkcCoCEkFu9OAkUAV-A.jpeg" /><figcaption>Photo of the Hawthorne Bridge in Portland by <a href="https://unsplash.com/@rydama?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ryan Manwiller</a> on <a href="https://unsplash.com/photos/he5iQ3hgbv8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>.</figcaption></figure><p>At the Department of Veterans Affairs (VA) Big Data Genomics group, our job is to build and maintain robust cloud based infrastructure to manage, process, and analyze large scale genomic datasets. As a small group in a rapidly evolving field, we are under constant pressure to expand our offerings and generate new datasets. Our challenge is to establish a framework for adding new features while also sustaining existing ones, all while the size of our datasets gets steadily larger. By taking lessons from physical systems, we can learn to better manage our digital ones.</p><h3>Focus on The Process</h3><p>A lot of the internal and external pressure on our group is in regards to generating data, because our stakeholders need data to generate results, and all of the incentives in academia are structured around results. Nobody awards grants for maintenance. It’s tempting to conform to these pressures and choose the shortest path towards generating data and getting results. However, the shortest path to results is to forego establishing robust, well documented, reproducible methods; which is why so much scientific research is not reproducible.</p><p>And while the “<a href="https://www.nature.com/articles/533452a">crisis</a>” of reproducibility is an abstract one for most researchers, it is of immediate concern to us because our job is to repeat these methods to generate larger and larger datasets ad infinitum. And the bigger the data, the greater the strain on the scalability of our methods.</p><p>We don’t build roads but we do build infrastructure, and when I think of the importance of building and maintaining robust infrastructure, I think of my local Portland Bureau of Transportation (PBOT). PBOT currently has a <a href="https://bikeportland.org/2022/11/02/whats-behind-pbots-4-4-billion-street-maintenance-backlog-excuse-366371">$4.4 billion</a> maintenance backlog. This has all kinds of negative consequences:</p><ul><li>Rejection of new projects</li><li>Frustration of PBOT workers who can’t address problems</li><li>Frustration of residents who want good infrastructure</li></ul><p>And every year the maintenance issues go unresolved, the burden of using their infrastructure increases, as does the cost of fixing it, creating a negative feedback loop that will take massive investment to resolve.</p><p>So, how did they get there? Well, it didn’t take long. In 2005, the maintenance backlog only amounted to $28 million. Official site multiple causes:</p><ul><li>Inadequate maintenance funds for expensive infrastructure</li><li>Lack of political will: maintenance isn’t sexy</li><li>Bigger and heavier vehicles</li><li>Federal grant programs don’t pay for maintenance (Hello, NIH!)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02x_ugUWHFqz-TpqtYRpBA.png" /><figcaption>Cost of PBOT maintenance backlog over time. Image generated by City of Portland &amp; provided by BikePortland.</figcaption></figure><p>How are they going to fix it? Not easily and not soon. So, what lessons can we translate to bioinformatics infrastructure?</p><ul><li>Focus on maintaining existing systems from the outset. Once you get into a hole, it’s difficult to get out.</li><li>Regulate usage of your infrastructure to sustainable methods. Less repeatable means more expensive to maintain.</li><li>Budget maintenance into your capacity for projects and assume that every resource requires maintenance to address things like bigger datasets, new types of data, software updates, and cloud platform updates</li><li>Measure the time you are spending on each project. How does actual time spent match your expectations?</li></ul><h3>Establish Standard Practices &amp; Specifications</h3><p>Expanding features and services with minimal labor cost is a significant challenge. Another, more positive example from PBOT demonstrates a strategy for doing so.</p><p>One of the projects that has been hamstrung by PBOT’s budget woes is the expansion of bike lanes. But, in 2022, they got a new section of <a href="https://bikeportland.org/2022/10/28/a-global-corporation-paid-for-and-built-protected-bike-lanes-on-nw-front-ave-366380">bike lanes</a> built at no cost to the city. How did they do it? They didn’t. They provided specifications for the bike lanes and a local corporation hired contracts to install them near their headquarters. Why they did it somewhat questionable (people had been parking RVs along that strip of road), but ethics aside, the city got new infrastructure at no cost. Again, how does this apply to digital infrastructure?</p><p><strong>Publish specifications for extending infrastructure.</strong></p><p>If others want to extend our infrastructure with new algorithms or features, let them. Ideally, provide tutorials for development, testing, and validation. Just make sure their additions meet the specifications you have established. Introducing variability into the system will make it more complicated and harder to maintain. Can you write automated tests to validate that new features meet specifications? Teach people to fish, rather than giving them fish.</p><p><strong>Establish a strategy for expanding infrastructure.</strong></p><p>The new bike lanes weren’t placed arbitrarily, they were added in accordance with PBOT’s Bicycle Plan for 2030, an overarching plan that includes a map of bike lanes intended to be added over a 20 year period.</p><p>When PBOT, an institution tasked with advancing the public good, adds a bike lane they aren’t just creating a path; they are indicating to the public that they <em>should</em> bike there. It signals to the public that “We experts have studied traffic patterns and added this path because it is optimal route for cycling to some place.” If people use the path and find that it is not an ideal route, it erodes public confidence in the entire institution.</p><p>As a data generator, our goal is to provide high quality datasets to all researchers in the <a href="https://www.research.va.gov/mvp/">Million Veteran Program</a>. By adding infrastructure to generate a new dataset for researchers, we are tacitly endorsing that dataset; that we have vetted the algorithm that generated it, validated the results, and are confident in the quality of the data. By performing this due diligence we allow researchers to focus on analyzing the data rather than validating it.</p><p>By adhering to these principles, we can transition from research-grade to enterprise-grade infrastructure, and establish a foundation that will support new features and ever expanding data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc13c0ff1893" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Hail on a Vertex AI notebook]]></title>
            <link>https://medium.com/@pbilling_97992/run-hail-on-a-vertex-ai-notebook-e9eb94f3fe9c?source=rss-5f1121fc246------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9eb94f3fe9c</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <dc:creator><![CDATA[Paul Billing-Ross]]></dc:creator>
            <pubDate>Mon, 10 Oct 2022 12:01:50 GMT</pubDate>
            <atom:updated>2022-10-10T12:01:50.930Z</atom:updated>
            <content:encoded><![CDATA[<p>Use the distributed genomics library on a single GCP instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQZqqySDRdOKluoNuCwwWA.jpeg" /><figcaption>Image of statue of Caesar by <a href="https://pixabay.com/users/m-carlos-5412835/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2766395">MATEO</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2766395">Pixabay</a>. Freely distributed under Pixabay license.</figcaption></figure><p>The Hail Python library is designed for running large scale genomics analyses distributed across a computing cluster. And while running complex procedures like genome aggregation, filtering, or population level quality control may require extensive computing resources, sometimes I just want to take a look at the data, generate visualizations, or play around with a smaller dataset. In these cases, a single virtual machine instance can suffice.</p><p>The Vertex AI workbench provides a handy interface for launching virtual machines preconfigured with JupyterLab and a host of analysis libraries, on Google Cloud Platform. It’s also got a one-click button for pulling up a JupterLab session in your browser. Workbench instances also provide a consistent computing environment that can be reproduced by anyone else using the platform, which is essential for scientific analyses. Because of the ease of use, flexibility in allocating compute resources (CPUs and memory), and reproducible environments, I use these instances as my default workspace. And with these few additional steps, I can also run Hail on them.</p><h3>Create a Vertex AI instance</h3><ul><li>Navigate to the Vertex AI notebooks workbench through the Google Cloud Platform web interface (<a href="https://console.cloud.google.com/vertex-ai/workbench">https://console.cloud.google.com/vertex-ai/workbench</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*GzRmZwpbx8aR4wQ7uR-HEg.png" /><figcaption>Screenshot of the Vertex AI Workbench web interface</figcaption></figure><ul><li>Click on the <strong>NEW NOTEBOOK</strong> button at the top and select <strong>Python 3</strong> from the dropdown menu.</li><li>Choose a name, region, zone, and subnetwork. You can probably leave the region, zone, and subnetwork as is. In a basic project, the subnetwork should default to “datalab-network”, but I’ve found that if you have multiple subnetworks it will choose the first one, sorted alphabetically. For the sake of consistency and to make sure your notebook doesn’t end up in a subnetwork designated for another use case, I recommend using “datalab-network”.<br>- <strong>Notebook</strong> <strong>name</strong>: my-hail-vertex-notebook<br>- <strong>Region</strong>: us-west1 (Hello, west coasters!)<br>- <strong>Zone</strong>: us-west1-b<br>- <strong>Subnetwork</strong>: datalab-network</li><li>Before creating your notebook, click on the <strong>ADVANCED OPTIONS</strong> button in the bottom left of the “New notebook” panel.</li><li>Under <strong>Environment</strong>, choose <strong>Ubuntu</strong> (current version: 20.04) from the <strong>Operating System</strong> dropdown menu. I recommend this because I’ve had issues using the root user when running Debian.</li><li>Under <strong>Machine configuration</strong>, you can change the machine type to use for the notebook. I usually start with an <strong>e2-standard-4</strong> machine and will shut down the notebook and select a different machine type if I run out of resources. And if I get an error running Hail, it’s usually because I ran out of memory. I also shut down these instances whenever I’m not using them to save money while still preserving my workspace.</li><li>OK! You should be good to launch your Vertex AI instance. Scroll to the bottom of the “Create a user-managed notebook” page and slam that blue <strong>CREATE</strong> button.</li></ul><h3>Configure your instance to use Hail</h3><ul><li>Once you create your Vertex instance, you should be returned to the <strong>Workbench </strong>dashboard which shows a list of all your instances. Once you see a green checkmark next to yours, click on the <strong>OPEN JUPYTERLAB</strong> blue text to open up a JupyterLab interface in your web browser.</li><li>You should land on the <strong>Launcher</strong> page in JupterLab. From there, click on the <strong>Terminal</strong> button with an icon that looks like <strong>$_ </strong>to open a new terminal instance on your new Vertex virtual machine. If you don’t see this button, you can also navigate to the File button in the menubar at the top of the screen. Click on <strong>File</strong> and from the dropdown menu select <strong>New &gt; Terminal</strong>. In your new terminal window, you should see a prompt that looks like this:</li></ul><pre>To run a command as administrator (user “root”), use “sudo &lt;command&gt;”.<br>See “man sudo_root” for details.</pre><pre>(base) jupyter@my-hail-vertex-notebook:~$</pre><ul><li>Copy, paste, and run each line of the following code block in your terminal, to install Java 11. After running the second command, you will receive a “<strong>Do you want to continue [Y/n]</strong>” prompt. Press <strong>y</strong> and then <strong>Enter</strong> to accept. Note that Hail requires either Java 8 or 11 to run. Hopefully pretty straightforward, but I recommend this DigitalOcean <a href="https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-debian-10">tutorial</a> for more information on managing Java.</li></ul><pre>sudo apt update<br>sudo apt install default-jre<br>java -version</pre><ul><li>After running java -version you should see output that looks like the following.</li></ul><pre>openjdk version “11.0.16” 2022–07–19<br>OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)<br>OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)</pre><ul><li>Install Hail by running the following Python command in the terminal. Note that upon completion, you may see an error message claiming that pip&#39;s dependency resolver does not currently take into account all the packages that are installed. This does not seem to interfere with Hail functionality and you can ignore. Below the error you should see Successfully installed...and a list of packages.</li></ul><pre>python3 -m pip install hail</pre><ul><li>Authenticate your Google credentials with gcloud in order to install and use the Google Cloud Storage connector. Run the command and follow the subsequent instructions.</li></ul><pre>gcloud auth application-default login</pre><ul><li>Install the Google Cloud Storage connector. This will allow Hail to read objects directly from cloud storage. From the Hail docs (<a href="https://hail.is/docs/0.2/cloud/google_cloud.html#">https://hail.is/docs/0.2/cloud/google_cloud.html#</a>):</li></ul><pre>curl -sSL https://broad.io/install-gcs-connector | python3</pre><h3>Validate that Hail is working</h3><ul><li>Start a Python interactive session</li></ul><pre>python3</pre><ul><li>Try grabbing sample data from Google Cloud Storage by running the following commands in Python. See the <a href="https://hail.is/docs/0.2/tutorials/01-genome-wide-association-study.html">Hail GWAS tutorial</a> for more information.</li></ul><pre>import hail as hl<br>hail.init()<br>hl.utils.get_1kg(&#39;data/&#39;)</pre><ul><li>You should see something like the following.</li></ul><pre>&gt;&gt;&gt; hl.utils.get_1kg(‘data/’)<br>2022–10–07 00:14:31 Hail: INFO: downloading 1KG VCF …<br> Source: <a href="https://storage.googleapis.com/hail-tutorial/1kg.vcf.bgz">https://storage.googleapis.com/hail-tutorial/1kg.vcf.bgz</a><br>2022–10–07 00:14:32 Hail: INFO: importing VCF and writing to matrix table…<br>2022–10–07 00:14:33 Hail: INFO: scanning VCF for sortedness…<br>2022–10–07 00:14:37 Hail: INFO: Coerced sorted VCF — no additional import work to do=============&gt; (8 + 4) / 16]<br>2022–10–07 00:14:42 Hail: INFO: wrote matrix table with 10879 rows and 284 columns in 16 partitions to data/1kg.mt=================================================&gt; (14 + 2) / 16]<br>2022–10–07 00:14:42 Hail: INFO: downloading 1KG annotations …<br> Source: <a href="https://storage.googleapis.com/hail-tutorial/1kg_annotations.txt">https://storage.googleapis.com/hail-tutorial/1kg_annotations.txt</a><br>2022–10–07 00:14:42 Hail: INFO: downloading Ensembl gene annotations …<br> Source: <a href="https://storage.googleapis.com/hail-tutorial/ensembl_gene_annotations.txt">https://storage.googleapis.com/hail-tutorial/ensembl_gene_annotations.txt</a><br>2022–10–07 00:14:43 Hail: INFO: Done!<br>&gt;&gt;&gt;</pre><ul><li>Now try running their GWAS tutorial, to get the full Hail experience (<a href="https://hail.is/docs/0.2/tutorials/01-genome-wide-association-study.html">https://hail.is/docs/0.2/tutorials/01-genome-wide-association-study.html</a>).</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9eb94f3fe9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to mock Neo4j database responses using the Python driver]]></title>
            <link>https://medium.com/@pbilling_97992/how-to-mock-neo4j-database-responses-using-the-python-driver-71bd30000ac2?source=rss-5f1121fc246------2</link>
            <guid isPermaLink="false">https://medium.com/p/71bd30000ac2</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[neo4j]]></category>
            <dc:creator><![CDATA[Paul Billing-Ross]]></dc:creator>
            <pubDate>Fri, 16 Sep 2022 12:02:15 GMT</pubDate>
            <atom:updated>2022-09-16T12:02:15.662Z</atom:updated>
            <content:encoded><![CDATA[<h4>Incorporate mock database responses into your unit tests</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*oiNCCTOvvYGH7mcOmZ4YNg.jpeg" /><figcaption>Epson Equity 1 drawing available under a CC0 1.0 license at <a href="https://commons.wikimedia.org/wiki/File:Epson_Equity_I_drawing_(1987).jpg">Wikimedia Commons</a></figcaption></figure><p>I use Neo4j as the database for my <a href="https://trellis-data-management.readthedocs.io/">data and task management application</a>. All of the application operations are initiated by database changes. Because database responses are so essential to the application functions, I want to be able to incorporate them into unit tests.</p><p>After some searching, I found tools for <a href="https://neo4j.com/developer-blog/how-to-mock-neo4j-calls-in-node/">mocking Neo4j responses in Node</a>, <a href="https://community.neo4j.com/t5/drivers-stacks/is-there-a-library-to-unit-test-graphdb-cypher-queries-using/m-p/32385">validating Cypher queries</a>, and performing complex <a href="https://github.com/neo4j-drivers/testkit">integration tests</a>. None of these quite fit what I had in mind; I use Python, I’m not concerned with query validation, and I’m looking for something fairly simple that doesn’t require Docker or a running Neo4j instance. So, I opted to use the Neo4j Python driver to mock database responses.</p><h3>Processing Neo4j queries using the Python driver</h3><p>First, an example of how the application interacts with the Neo4j driver. I use parameterized queries so that I can generate summary metrics and they are all processed the same way, returning a <a href="https://neo4j.com/docs/api/python-driver/current/api.html#neo4j.graph.Graph">Graph</a> and a <a href="https://neo4j.com/docs/api/python-driver/current/api.html#resultsummary">ResultSummary</a>. These are the classes of objects I wanted to mock.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e39388c1aefd644241f548a844723e09/href">https://medium.com/media/e39388c1aefd644241f548a844723e09/href</a></iframe><pre>&lt;Node id=225 labels=frozenset({&#39;Person&#39;}) properties={&#39;name&#39;: &#39;Inaayah&#39;}&gt;<br>729</pre><p>The <a href="https://neo4j.com/docs/api/python-driver/current/api.html">driver documentation</a> showed me how I could interact with objects of these classes, but I still wasn’t sure how to create instances of them myself. Source code for the driver is publicly available on <a href="https://github.com/neo4j/neo4j-python-driver">GitHub</a> so I started there.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b40beddf72d25bdb6b04c1776b0eac2f/href">https://medium.com/media/b40beddf72d25bdb6b04c1776b0eac2f/href</a></iframe><p>The initialization methods for the graph classes looked fairly simple, so I tried blindly creating a simple graph with a single node.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec4274d48869cecc3c3c576ea4ae65a6/href">https://medium.com/media/ec4274d48869cecc3c3c576ea4ae65a6/href</a></iframe><pre>Node: &lt;Node id=1 labels=frozenset({&#39;Person&#39;}) properties={&#39;name&#39;: &#39;Anaayah&#39;}&gt;</pre><p>Here, I ran into a bit of a “chicken and egg” situation where in order to create a node, I needed a graph, but then once I had the node I couldn’t figure out how to add it back to the graph.</p><p>To better understand how to interact with these classes, I looked for examples by searching the term “Graph()” in the driver repository. That led me to <a href="https://github.com/neo4j/neo4j-python-driver/blob/97be40c9de40116ecda5d2bf4f1c9fc6e7e580d2/tests/unit/common/test_types.py">unit tests</a> for the driver where I discovered there is a nested Hydrator class within Graph that is used for “hydrating” entities into graph objects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d78a32fa2d310dc2b96ef6d05442cfc/href">https://medium.com/media/0d78a32fa2d310dc2b96ef6d05442cfc/href</a></iframe><p>Reflecting back, I probably could have figured this out by just looking through the entire Graph class definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*xWShlspCp-aoE8FL1WYyxw.png" /><figcaption>I try not to. (From <a href="https://twitter.com/girba/status/1551159516221276162?s=20&amp;t=v9Gnw-gWAdAa6WA85wcrVw">Twitter</a>)</figcaption></figure><p>Based on the developer tests, I wrote my own code to mock Neo4j responses. <strong>Note</strong> that the driver is under active development, so the test file I referenced here has already changed in version 5.0 to match the changing state of the driver.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f71bb44b9c4eb312289d5777b4151db8/href">https://medium.com/media/f71bb44b9c4eb312289d5777b4151db8/href</a></iframe><p>Since the patterns I’m using match those in the driver tests, I’m confident that they mirror actual responses generated from the API. But, for the sake of due diligence (and narrative completeness) I compared real to mock results.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c007f7c96a8fb9a9d685699c621f1dc/href">https://medium.com/media/9c007f7c96a8fb9a9d685699c621f1dc/href</a></iframe><p>I initially tried using the equality operator “==” to compare nodes and relationships but those assertion statements returned “false”. Looking at the equality function for the <a href="https://github.com/neo4j/neo4j-python-driver/blob/97be40c9de40116ecda5d2bf4f1c9fc6e7e580d2/neo4j/graph/__init__.py">Neo4j Entity class</a> (of which Node and Relationship classes are derived), I saw it compares types, graphs, and element IDs. Since entities from the live database were associated with a different graph than the mock ones, I opted to just check equality of individual attributes.</p><p>I didn’t end up doing the comparison between live/mock ResultSummary objects because it seemed like too much of a pain and I’m not that concerned with those results. But, here is how I mock result summaries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3009015eb30f8e1aa9b251a730d1dc60/href">https://medium.com/media/3009015eb30f8e1aa9b251a730d1dc60/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71bd30000ac2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rabbit and The Moon]]></title>
            <link>https://medium.com/@pbilling_97992/rabbit-and-the-moon-bb37df0d0b37?source=rss-5f1121fc246------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb37df0d0b37</guid>
            <dc:creator><![CDATA[Paul Billing-Ross]]></dc:creator>
            <pubDate>Sun, 11 Sep 2022 01:01:45 GMT</pubDate>
            <atom:updated>2022-09-11T01:01:45.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Rabbit sat in the small field next to the post office, looking anxiously at the moon. Sparrow landed on a branch near rabbit.<br>“Why do you look so concerned, rabbit?”, asked Sparrow.<br>“There will not be enough food for my family, this winter”, responded Rabbit.<br>“Can’t you gather more food?” <br>“No, it is too late in the season.”<br>“So, what will you do?”<br>“I don’t know”, replied Rabbit.</p><p>The two sat in silence for a while.<br>Finally, Sparrow piped up, “I’ve heard that there is plenty of food across the river.”<br>“How can I cross the river?”, asked Rabbit, “It’s so deep.”<br>“There is a log that crosses it, I’ve seen it”, said Sparrow.<br>“But how will I find it in the dark?”<br>“The moon will show you, Rabbit, it’s full and bright tonight.”</p><p>And so the two headed off to cross the river.<br>But as they neared the log, Hawk spotted them in the moonlight.<br>As Hawk dove towards them, Sparrow cried out,<br>“Run Rabbit, get across the river!”<br>And Rabbit scampered across the field,<br>and through bushes,<br>and over the log.</p><p>When he had crossed the river he peered up at the sky, <br>but he didn’t see Hawk or Sparrow,<br>only the moon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb37df0d0b37" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>