<?xml version= "1.0" encoding= "utf-8" standalone= "yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Open-Source on Spinning Code</title>
    <link>https://spinningcode.org/tags/open-source/</link>
    <description>Recent content in Open-Source on Spinning Code</description> <generator>Hugo -- 0.157.0</generator>
    <language>en-US</language> <lastBuildDate>Sat, 04 Dec 2021 20:09:43 +0000</lastBuildDate> <atom:link href= "https://spinningcode.org/tags/open-source/feed.xml" rel= "self" type= "application/rss+xml" /> <item>
      <title>Announcing Two New Snowfakery Faker Providers</title>
      <link>https://spinningcode.org/2021/12/announcing-two-new-snowfakery-faker-providers/</link>
      <pubDate>
        Sat, 04 Dec 2021 20:09:43 +0000
      </pubDate> <guid
        isPermaLink="false">https://spinningcode.org/?p=1779</guid>  <description>This week I helped create two new faker providers for Snowfakery: Faker Nonprofit and Faker EDU</description> <content:encoded><![CDATA[<p>For the last two years I&rsquo;ve been fortunate to serve as a leader of the <a href="https://github.com/SFDO-Community-Sprints/DataGenerationToolkit">Salesforce Open Source Commons Data Generation Toolkit project</a>. That project has produced and inspired a variety of efforts, including <a href="https://github.com/SFDO-Tooling/Snowfakery">Snowfakery</a> and a <a href="https://github.com/SFDO-Community-Sprints/Snowfakery-Recipe-Templates">collection of starter recipes</a>.</p>
<p>This week, along with my colleague <a href="https://github.com/allisonletts">Allison Letts</a>, Salesforce&rsquo;s <a href="https://www.linkedin.com/in/paulprescod/">Paul Prescod</a> (the creator of Snowfakery), and our fellow project contributor <a href="https://GitHub.com/eehjunggnujhee">Jung Mun</a>, I helped create two new faker providers for Snowfakery:</p>
<ul>
<li><a href="https://pypi.org/project/faker-nonprofit/">Faker Nonprofit</a></li>
<li><a href="https://pypi.org/project/faker-edu/">Faker EDU</a></li>
</ul>
<h2 id="what-these-faker-providers-do">What These Faker Providers do</h2>
<p>The use of Snowfakery is growing. The more we use it, the more we want the data tailored to specific projects. And the more we find places where the <a href="https://faker.readthedocs.io/en/master/">Faker project&rsquo;s</a> providers do not have quite what we want. In particular the project does not (well did not) have providers for nonprofits and education specific data.</p>
<p>The Nonprofit provider currently just provides organization names:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ snowfakery snowfakery_nonprofit_example.recipe.yml --target-count <span style="color:#ae81ff">10</span> nonprofit
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>1, nonprofit_name<span style="color:#f92672">=</span>Eastern Animal Asscociation<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>2, nonprofit_name<span style="color:#f92672">=</span>1st Animal Foundation<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>3, nonprofit_name<span style="color:#f92672">=</span>Upper Peace Alliance<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>4, nonprofit_name<span style="color:#f92672">=</span>Southern Peace Home<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>5, nonprofit_name<span style="color:#f92672">=</span>Unity Home<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>6, nonprofit_name<span style="color:#f92672">=</span>Western Peace Home<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>7, nonprofit_name<span style="color:#f92672">=</span>Upper History Foundation<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>8, nonprofit_name<span style="color:#f92672">=</span>Upper Friends Committee<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>9, nonprofit_name<span style="color:#f92672">=</span>Eastern Pets Center<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>nonprofit<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>10, nonprofit_name<span style="color:#f92672">=</span>Northern Animal Foundation<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>For the Education provider we have a bit more. You can generate college names, departments, and faculty titles.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ snowfakery snowfakery_edu_example.recipe.yml
</span></span><span style="display:flex;"><span>Account<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>1, Name<span style="color:#f92672">=</span>South Carolina University<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Contact<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>1, FirstName<span style="color:#f92672">=</span>Roberto, LastName<span style="color:#f92672">=</span>Stanton, Title<span style="color:#f92672">=</span>Associate Professor of Microbiology &amp; Immunology<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Account<span style="color:#f92672">(</span>id<span style="color:#f92672">=</span>2, Name<span style="color:#f92672">=</span>French<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>The providers can of course run as a standard faker community provider. Once you are <a href="https://faker.readthedocs.io/en/master/#basic-usage">setup with Faker</a> just add the new providers with pip:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pip install faker-edu faker-nonprofit
</span></span></code></pre></div><p>Then you can use the libraries in your code:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> faker <span style="color:#f92672">import</span> Faker
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> faker_edu
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>fake <span style="color:#f92672">=</span> Faker()
</span></span><span style="display:flex;"><span>fake<span style="color:#f92672">.</span>add_provider(faker_edu<span style="color:#f92672">.</span>Provider)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> _ <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">10</span>):
</span></span><span style="display:flex;"><span>    print(fake<span style="color:#f92672">.</span>institution_name())
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> faker <span style="color:#f92672">import</span> Faker
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> faker_nonprofit
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>fake <span style="color:#f92672">=</span> Faker()
</span></span><span style="display:flex;"><span>fake<span style="color:#f92672">.</span>add_provider(faker_nonprofit<span style="color:#f92672">.</span>Provider)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> _ <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">10</span>):
</span></span><span style="display:flex;"><span>    print(fake<span style="color:#f92672">.</span>nonprofit_name())
</span></span></code></pre></div><h2 id="how-we-got-here">How we got here</h2>
<p>A few months ago I posted on how to <a href="/2021/05/snowfakery-custom-plugins-part-1/">extend Faker to create nonprofit organization names</a>. Allison took that as a starting point to create <a href="https://github.com/allisonletts/faker_highered">a similar project</a> to generate names of colleges, departments, and academic titles (and a <a href="https://github.com/allisonletts/faker_phone_NorthAmericanNumberingPlan">greatly improved phone number generator</a> but that&rsquo;s not included since it&rsquo;s more general). Both of these projects were good proof-of-concept but were rough around the edges. So this week, with Paul&rsquo;s guidance and Jung&rsquo;s input, we contributed the more polished versions to the community.</p>
<p>During a virtual working session on Wednesday we restructured the projects, cleaned up code, added sample recipes for Snowfakery, and published them to PyPi. By publishing these as Faker providers on PyPi, and not as Snowfakery plugins, they are available to a wider audience. By having them owned by a larger open source community we are expecting them to enjoy long-term support.</p>
<p>Both are still just getting started. For example the nonprofit one still just generates organization names, but would benefit from job titles, program names, and more. The EDU provider right now just handles colleges, but is expected to generate other education related data in the future. We also have a plan for a third provider to help improve the diversity of the names generated by Faker to make our fake data more representative of real communities.</p>
<p>The Data Generation Toolkit project has been a great example of what happens when you bring people from a wide variety of backgrounds together to solve technical problems. Like the larger Data Generation Toolkit team Paul, Allison, Jung, and I all have different backgrounds, skills, and experiences. By coming together we are able to help each other find better solutions than any one of us would have found on our own.</p>
<p>It&rsquo;s been an exciting week, and I&rsquo;m looking forward to more to come.</p>
]]></content:encoded> </item> </channel>
</rss>
