<?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: Yuki Inoue</title>
    <description>The latest articles on DEV Community by Yuki Inoue (@yukiinoue).</description>
    <link>https://dev.to/yukiinoue</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%2F47348%2F044cdf0c-fd78-4e29-ad40-e5e14ad58de6.png</url>
      <title>DEV Community: Yuki Inoue</title>
      <link>https://dev.to/yukiinoue</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yukiinoue"/>
    <language>en</language>
    <item>
      <title>The Most Important Task For Every OSS Maintainer</title>
      <dc:creator>Yuki Inoue</dc:creator>
      <pubDate>Tue, 16 Apr 2019 01:32:49 +0000</pubDate>
      <link>https://dev.to/yukiinoue/the-most-important-task-for-every-oss-maintainer-11pi</link>
      <guid>https://dev.to/yukiinoue/the-most-important-task-for-every-oss-maintainer-11pi</guid>
      <description>&lt;p&gt;Is to release the library whenever new feature or bugfix is merged into the master.&lt;/p&gt;

&lt;p&gt;More descriptively, on modern development environment OSS is generally hosted on the Github.  If so, they are likely to be adopting (explicitly or implicitly) &lt;a href="https://guides.github.com/introduction/flow/"&gt;the development flow of Github flow&lt;/a&gt;.  In this style of development, every commit against master branch is a release candidate.  Since it is a release candidate, it can always be released as &lt;code&gt;pre-release&lt;/code&gt; version, if the versioning system adopted by the language library ecosystem supports &lt;a href="https://semver.org/#spec-item-10"&gt;Semantic Versioning&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When the library maintainer keep publishing whatever is merged into &lt;code&gt;master&lt;/code&gt;, what the library user need to do is to manage libraries systematically according to their needs.  Since Semantic Versioning defines linear ordering against every released version, one can expect the library managing tool (e.g. &lt;code&gt;npm&lt;/code&gt;, &lt;code&gt;gem&lt;/code&gt;) of each language to do those management well.  On the other hand, when some feature/bugfix is merged into develop but not yet released, the library user generally need to handle "the source location to fetch specific library" (e.g. git url along with branch/tag/ref).  Since all the other libraries specify their dependency by some constraints against the released version, that means the library user would have now manage &lt;code&gt;versioning&lt;/code&gt; and &lt;code&gt;source location&lt;/code&gt; for that library.  I believe it is something that no library user wants.&lt;/p&gt;

&lt;p&gt;I know that to maintain OSS, there many other tasks too.  But releasing operation can be simply done if release policy is made.  For example, just release every new master commit as new major/minor/patch release depending on the content of the commit made; major release if breaking changes, minor release if new feature, patch release if bug fix, do them as pre-release if you are not certain the commit won't break anything.  If such policy is made, then what the maintainer needs to do can be made into just a single command, by automating the deploy procedure.  By doing this, it can bring benefit to all the users of that library, IMHO...   So, I sincerely hope every OSS maintainer kindly publishes their fabulous libraries regularly.&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>Integrating Jupyter Notebook and Rails</title>
      <dc:creator>Yuki Inoue</dc:creator>
      <pubDate>Mon, 04 Mar 2019 16:45:17 +0000</pubDate>
      <link>https://dev.to/yukiinoue/integrating-jupyter-notebook-and-rails-43cc</link>
      <guid>https://dev.to/yukiinoue/integrating-jupyter-notebook-and-rails-43cc</guid>
      <description>&lt;p&gt;If you have ever worked on Jupyter and Rails, you'd probably wanted to execute Rails codes inside the Jupyter Notebook.  Although it was already possible to achieve it, the experience was not so good; not as slick as those developer experience you get when you are riding the rail.&lt;/p&gt;

&lt;p&gt;To tackle this problem and make Rails Jupyter friendly, I've made a gem called &lt;code&gt;jupyter_on_rails&lt;/code&gt;.  With this gem, working on a Rails project will get helped by the power of Jupyter (Notebook).&lt;/p&gt;

&lt;h1&gt;
  
  
  What is achieved
&lt;/h1&gt;

&lt;p&gt;By adding following gems to your Rails project's &lt;code&gt;Gemfile&lt;/code&gt; and making the &lt;code&gt;bundle install&lt;/code&gt; succeed,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'jupyter_on_rails'&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'ffi-rzmq'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following things are achieved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rake jupyter:notebook&lt;/code&gt; command to start a Jupyter Notebook server with your Rails app's kernel installed at your project local.

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;iruby&lt;/code&gt; kernel configuration is confined to your project;  no more troubles of global &lt;code&gt;iruby&lt;/code&gt; configuration headache, if you know what I mean.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Some methods which makes it easy to operate ActiveRecord operations on Jupyter Notebook.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Here is the example screenshot of what you'll achieve:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmzc5v4212ol77sxxd4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmzc5v4212ol77sxxd4x.png" alt="Jupyter on Rails" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Detail
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To use &lt;code&gt;jupyter_on_rails&lt;/code&gt;, you need to have &lt;code&gt;jupyter&lt;/code&gt; available at your project, and you need to have all the libraries needed for the installation of dependency gems to be success.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;jupyter&lt;/code&gt; command, you have 2 options.  One is installing globally by using e.g. &lt;code&gt;pip install jupyter&lt;/code&gt;, or by creating &lt;code&gt;pipenv&lt;/code&gt; environment at your project root and having &lt;code&gt;jupyter&lt;/code&gt; there.  My personal recommendation is using the Pipenv.  For those rubyists who is unfamiliar with &lt;code&gt;pipenv&lt;/code&gt;, it is a &lt;code&gt;bundler&lt;/code&gt; for python.&lt;/p&gt;

&lt;p&gt;You can check whether Jupyter notebook is properly installed by executing:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jupyter notebook
# or, for those who use pipenv
$ pipenv run jupyter notebook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If jupyter notebook web page is opened, then the &lt;code&gt;jupyter&lt;/code&gt; installation is success.&lt;/p&gt;

&lt;p&gt;Next, you need to install the libraries needed for the dependencies of &lt;code&gt;jupyter_on_rails&lt;/code&gt; and &lt;code&gt;ffi-rzmq&lt;/code&gt;.  For this, since I cannot remember what was exactly needed for these gems, please refer to each gem's installation instruction if any &lt;code&gt;bundle install&lt;/code&gt; error occurs.  I can tell that all the required libraries could be installed by using Homebrew if you're using Mac.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding &lt;code&gt;jupyter_on_rails&lt;/code&gt; to mac and launching Jupyter
&lt;/h2&gt;

&lt;p&gt;Once you have your jupyter ready, put following dependencies in your &lt;code&gt;Gemfile&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'jupyter_on_rails'&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'ffi-rzmq'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;code&gt;bundle install&lt;/code&gt;.  Install libraries to make install success if necessary.&lt;/p&gt;

&lt;p&gt;After that, you can execute following command, to launch a Jupyter which have your app's kernel installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bin/rake jupyter:notebook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the image of what that command execution will be look like.  At top terminal, you can see the &lt;code&gt;rake jupyter:notebook&lt;/code&gt; command launching a jupyter server, at left bottom you see that when launching a new notebook, one can choose the rails app.  At right bottom you see &lt;code&gt;ApplicationRecord&lt;/code&gt;, one of the classes from the Rails context, can be used without any &lt;code&gt;require&lt;/code&gt;s or other configurations;  it should work out of the box.  (If you have used &lt;code&gt;rails console&lt;/code&gt;, then the kernel's context is exactly the same as that context.)&lt;/p&gt;

&lt;p&gt;If you have hard time looking at the image due to it's resize caused by CDN, refer to the original image at &lt;a href="https://raw.githubusercontent.com/Yuki-Inoue/jupyter_on_rails/master/the_screenshot.png" rel="noopener noreferrer"&gt;https://raw.githubusercontent.com/Yuki-Inoue/jupyter_on_rails/master/the_screenshot.png&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmi7mcqc19osy1foveeye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmi7mcqc19osy1foveeye.png" alt="jupyter kicked by rake command" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ActiveRecord integrations
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;jupyter_on_rails&lt;/code&gt; comes with some utility methods which helps you operate ActiveRecord on the notebook.&lt;/p&gt;

&lt;p&gt;Most notable is the &lt;code&gt;ActiveRecord::Relation#to_df&lt;/code&gt; method.  This turns your &lt;code&gt;ActiveRecord::Relation&lt;/code&gt; instance into &lt;code&gt;Daru::DataFrame&lt;/code&gt; instance.  For those unfamiliar with what a Dataframe is, it is a table like structure which can be used for further data manipulation.  It is also Jupyter friendly.  For those with python context, it is the &lt;code&gt;pandas.DataFrame&lt;/code&gt; in ruby.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcinfezlydvwc3mlvj86i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcinfezlydvwc3mlvj86i.png" alt="to_df" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows how &lt;code&gt;#to_df&lt;/code&gt; method works.  1. You can turn your model into DataFrame  2. The &lt;code&gt;includes&lt;/code&gt; is taken into account when creating DataFrame  3. It works on the Relation.&lt;/p&gt;

&lt;p&gt;So now, you have the DataFrame.  Refer to official documentation for how you work with the instance.  &lt;a href="https://github.com/SciRuby/daru" rel="noopener noreferrer"&gt;https://github.com/SciRuby/daru&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After modifications, you'd may want to write DataFrame data back to your model.  You can achieve it by &lt;code&gt;Daru::DataFrame#write_model(SomeModel)&lt;/code&gt;.  Below is again the screenshot of what its execution will look like.  Note that this is extension method against &lt;code&gt;daru&lt;/code&gt; made by &lt;code&gt;jupyter_on_rails&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1mkovu56l0foc6zjea0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1mkovu56l0foc6zjea0.png" alt="write_model" width="800" height="633"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Behind the scene
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;rake jupyter:notebook&lt;/code&gt; command creates an &lt;code&gt;.ipython&lt;/code&gt; configuration at the project root.  It basically copies the &lt;code&gt;iruby&lt;/code&gt; kernel configuration, and adds boot information there.  All the information needed for the kernel to boot rails is stored as configuration for kernel.  On each invocation of this kernel, &lt;code&gt;config/application.rb&lt;/code&gt; is loaded, and &lt;code&gt;application.initialize_environment!&lt;/code&gt; is called, so that Rails configuration is available.&lt;/p&gt;

&lt;h1&gt;
  
  
  Feedback, etc.
&lt;/h1&gt;

&lt;p&gt;Below is the Github project of this gem.  For bugs/feature requests, please submit them there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Yuki-Inoue/jupyter_on_rails" rel="noopener noreferrer"&gt;https://github.com/Yuki-Inoue/jupyter_on_rails&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>jupyter</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
