<?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: Rohit Farmer</title>
    <description>The latest articles on DEV Community by Rohit Farmer (@rohitfarmer).</description>
    <link>https://dev.to/rohitfarmer</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%2F153306%2Fc64a1c88-d3e9-4214-b59d-dc2451bbff8c.jpg</url>
      <title>DEV Community: Rohit Farmer</title>
      <link>https://dev.to/rohitfarmer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohitfarmer"/>
    <language>en</language>
    <item>
      <title>Keyoxide</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Sun, 03 Mar 2024 22:09:01 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/keyoxide-1g10</link>
      <guid>https://dev.to/rohitfarmer/keyoxide-1g10</guid>
      <description>&lt;p&gt;aspe:keyoxide.org:LYZNNNWNTWKBSQEDI46BBOEU3E&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Tweets from heads of governments and states</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Mon, 19 Sep 2022 20:27:28 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/tweets-from-heads-of-governments-and-states-29h2</link>
      <guid>https://dev.to/rohitfarmer/tweets-from-heads-of-governments-and-states-29h2</guid>
      <description>&lt;p&gt;Since October 2018, I have been maintaining a bot written in Python and running on a Raspberry Pi 3B+ that collects tweets from heads of governments and offices (worldwide) followed by &lt;a href="https://twitter.com/headoffice"&gt;https://twitter.com/headoffice&lt;/a&gt;. It was an excellent exercise learning Python, Twitter API, SQLite database, and using a Raspberry Pi for hobby projects. I have now released the data on Kaggle at &lt;a href="https://doi.org/10.34740/KAGGLE/DSV/4208877"&gt;https://doi.org/10.34740/KAGGLE/DSV/4208877&lt;/a&gt; for the community to use. &lt;/p&gt;

&lt;p&gt;The dataset contains an Excel workbook per year with data points on the rows and features on the columns. Features include the timestamp (UTC), language in which the tweet is written, user id, user name, tweet id, and tweet text. The first version includes the data from October 2018 until September 15, 2022. After that, future releases will be quarterly. It is a textual dataset and is primarily useful for analyses related to natural language processing.&lt;/p&gt;

&lt;p&gt;In the Kaggle submission, I have also included a notebook (&lt;a href="https://www.kaggle.com/code/rohitfarmer/dont-run-tweet-collection-and-preprocessing"&gt;https://www.kaggle.com/code/rohitfarmer/dont-run-tweet-collection-and-preprocessing&lt;/a&gt;) with the Python code that collected the tweets and the additional code that I used to pre-process the data before submission. After releasing the first data set, I updated the code and moved the bot from Python to R using the &lt;code&gt;rtweet&lt;/code&gt; library instead of &lt;code&gt;tweepy&lt;/code&gt;. I found &lt;code&gt;rtweet&lt;/code&gt; to perform better, especially in filtering out duplicated tweets. &lt;/p&gt;

&lt;p&gt;In the current setup (&lt;a href="https://github.com/rohitfarmer/government-tweets"&gt;https://github.com/rohitfarmer/government-tweets&lt;/a&gt;) that is still running on my Raspberry Pi 3B+, the main bot script runs every fifteen minutes via &lt;code&gt;crontab&lt;/code&gt; and fetches data that is more recent than the latest tweet collected in the previous run. The data is stored in an SQLite database which is backed up to MEGA cloud storage via Rclone once every midnight ET.&lt;/p&gt;

&lt;p&gt;I enjoyed the process of creating the bot and being able to run it for a couple of years, and I hope I will soon find some time to look into the data and fetch some exciting insights. But, until then, the data is available to the data science community to utilize as they please. So, please open a discussion on the Kaggle page for questions, comments, or collaborations. &lt;/p&gt;

&lt;p&gt;Day 13 of #100DaysToOffLoad&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>twitterbot</category>
      <category>nlp</category>
      <category>kaggle</category>
    </item>
    <item>
      <title>How to use Neovim or VIM Editor as an IDE for R</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Wed, 13 May 2020 00:43:32 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/how-to-use-neovim-or-vim-editor-as-an-ide-for-r-2ehi</link>
      <guid>https://dev.to/rohitfarmer/how-to-use-neovim-or-vim-editor-as-an-ide-for-r-2ehi</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/nm45WagtV3w"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In this tutorial, I demonstrate how to convert Neovim or VIM text editors into a fully functional IDE for R programming language. In addition to the primary plugin Nvim-R, I also show five other plugins that we can use to enhance our code editing capabilities in Neovim text editor.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>neovim</category>
      <category>rstats</category>
      <category>datascience</category>
    </item>
    <item>
      <title>How to Rip an Audio CD in Linux?</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Mon, 06 Apr 2020 13:39:53 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/how-to-rip-an-audio-cd-in-linux-4603</link>
      <guid>https://dev.to/rohitfarmer/how-to-rip-an-audio-cd-in-linux-4603</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SZP_--gXrpo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Ripping an audio CD means to copy the audio tracks from the CD to your computer in a format that is playable on devices other than a CD player, for example, your smartphone. There are multiple formats in which you can rip your audio CD, and they can be broadly divided into lossy (compressed) and lossless (uncompressed) formats. For example, MP3 is a lossy format, which means when you convert an audio track from an audio CD to an MP3, it loses some information. The loss of information makes the file size smaller that is easier to store without sacrificing much on detectable audio quality at least by most people listening on everyday non-specialized audio equipment. Lossless formats, on the other hand, preserves all the information that was originally recorded in the studio. The original lossless format in which CDs are written is called WAV. A typical 5 min song in WAV format takes around 50 Mb of disk space. With the storage costs lowering day by day, it may be acceptable for many of us to copy the WAV files without going through the hassle of converting them into any other format. However, one of the disadvantages of WAV format in addition to bulky file size is that it has the minimal capability to store metadata, for example, the name of the artist, album name, genre, album art etc. Lossless formats like FLAC that stands for Free Lossless Audio Codec can store metadata similar to MP3 in addition to higher quality sound as a WAV file. FLAC files also tend to be smaller than a WAV file. In reality, FLAC files are also compressed files similar to MP3; however, they don’t lose information as MP3 does. &lt;/p&gt;

&lt;p&gt;Links:&lt;br&gt;
Asunder: &lt;a href="http://www.littlesvr.ca/asunder/"&gt;http://www.littlesvr.ca/asunder/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>flac</category>
      <category>ripping</category>
      <category>asunder</category>
    </item>
    <item>
      <title>Essentials for Reproducibility</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Wed, 04 Sep 2019 21:30:55 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/essentials-for-reproducibility-1l79</link>
      <guid>https://dev.to/rohitfarmer/essentials-for-reproducibility-1l79</guid>
      <description>&lt;p&gt;Reproducibility of results is imperative for a sound research project. However, in computational research, especially in academic environments, we often overlook the reproducibility factor and does not put enough effort into establishing essential environments and workflows early on in the project lifecycle. Readers are often expected to figure things out themselves from the minimal information in the methods section if they want to reproduce the results themselves.  In this article, I discuss some of the practices that I have adopted in the past two years to make my work more reproducible. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Version Control:&lt;/strong&gt; Most important of all is to keep your code base under a &lt;a href="https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control"&gt;version control system (VCS)&lt;/a&gt;. I prefer &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;; however, other popular variants like &lt;a href="https://about.gitlab.com"&gt;GitLab&lt;/a&gt;, &lt;a href="https://bitbucket.org"&gt;Bitbucket&lt;/a&gt; are equally good. Posting your code online on GitHub not only serves the purpose of versioning it also acts as a backup. I have lost too many of my code in the past due to several reasons. Now I keep all my code posted on GitHub. If it is something embarrassingly trivial, then you can keep them in private repositories. At least they all will be there in case you might need to refer in the future. With all the code related to a project on GitHub, it becomes straightforward to share with collaborators or readers just by pointing them to the GitHub repository. If you happen to write a package or a module many programming languages can install your package directly from its GitHub repository without the need of posting it to a programming language-specific archive network. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt; Most of the academic projects run in between two to four years before you can publish an excellent paper. In addition to the project runtime, it is desirable for our results to be reproducible even after a decade. That is a very long time for most of the operating systems to stick around on the same version. In case of Windows and Mac OS, it might not even be possible to get a legal copy of an older version.  In contrast, at least in theory, you can always get an older version of a popular &lt;a href="https://distrowatch.com"&gt;Linux distribution&lt;/a&gt; that should install in a virtual machine. It can run the code written with old libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Containers:&lt;/strong&gt; Containers serves as a lighter version of a virtual machine that can encapsulate an operating system along with all the installed software and packages. A container image can be stored in a file and can be transferred easily from one computer to another. Docker is one of the most widely used container systems. &lt;a href="https://www.docker.com"&gt;Docker&lt;/a&gt; containers can be built from scratch or downloaded one of the pre-builts from their official vendors. If you are into scientific computing and frequently work in high-performance computing (HPC) environment, then &lt;a href="https://sylabs.io/singularity/"&gt;Singularity&lt;/a&gt; containers should be your choice. Singularity is now available by default on most of the academic HPCs, for example, all the HPCs provided by &lt;a href="https://www.xsede.org"&gt;XSEDE&lt;/a&gt; in the USA. Once a non-writable container is built, it freezes its contents in time and can be executed with its engine at any time in the future. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Environments:&lt;/strong&gt; Setting up a virtual environment for every project and fixing the library versions have multiple advantages. It provides you with an isolated environment to work with without tempering the global settings, and each project can have their selected versions of libraries. It prevents you from the hassle of resolving conflicts between multiple versions of libraries if installed globally. However, in contrast to virtual machines and containers, a virtual environment can only control for a specific set of libraries. It doesn't select an operating system.  I find &lt;a href="https://docs.conda.io/en/latest/"&gt;conda&lt;/a&gt; to be excellent for setting up environments. I use it for both Python and R. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documentation:&lt;/strong&gt; Never forget to document code both inside the scripts and outside in a lab book or a readme file. Often in a hurry to produce results and get feedback from our supervisor documentation is the first thing that we forget to do. It also seems to be least necessary while the project is running because we usually have all the facts on top of our heads. However, as time passes, there is only so much that the human brain can remember and recall at the time of need. It would not be surprising that you will forget the very details of the project that you were so confident and could recite in the middle of asleep at the time you were actively working on the project. Markdown readme files, Dropbox Paper, and GitHub wiki are some of my preferred ways to document my projects. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Originally posted at &lt;a href="https://rohitfarmer.github.io/datascience/2019/09/04/reproducibility/"&gt;https://rohitfarmer.github.io/datascience/2019/09/04/reproducibility/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reproducibility</category>
      <category>datascience</category>
      <category>research</category>
      <category>data</category>
    </item>
    <item>
      <title>Learning R: Rant 2</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Wed, 08 May 2019 19:57:05 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/learning-r-rant-2-3m44</link>
      <guid>https://dev.to/rohitfarmer/learning-r-rant-2-3m44</guid>
      <description>&lt;p&gt;Continuing my rant series while I am learning R. R is pretty much like Perl in terms of the philosophy that they follow; that is "There Is More Than One Way To Do It (TIMTOWTDI)". Although I appreciate this philosophy as it opens up the possibility of adopting multiple ways of doing the same thing. It becomes problematic when multiple people are working on the same project or worse if you are taking over someone else's project. Understanding the code becomes a pain in the back. Python, in this case, is a good language because it is more readable to a human and there are pretty much-set things on how to solve a particular kind of problem. Packages in R also have too many overlapping functions that mask each other in the order the packages are loaded. Therefore, you always need to be cautious about a function's source before calling it. &lt;/p&gt;

</description>
      <category>r</category>
      <category>datascience</category>
      <category>rant</category>
    </item>
    <item>
      <title>How-to run Jupyter notebook in an interactive node on a High-Performance Computer (HPC).</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Tue, 23 Apr 2019 23:00:00 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/how-to-run-jupyter-notebook-in-an-interactive-node-on-a-high-performance-computer-hpc-27mg</link>
      <guid>https://dev.to/rohitfarmer/how-to-run-jupyter-notebook-in-an-interactive-node-on-a-high-performance-computer-hpc-27mg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DZ9T-ekE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9509rdfdw2ad3r18lf6b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DZ9T-ekE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9509rdfdw2ad3r18lf6b.jpg" alt="Computer" width="880" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is an example protocol to run Jupyter notebook in an interactive node on a high-performance computer (HPCs). Most of the HPCs have their specialised way of interacting with them. Therefore, you may have to tweak this protocol as per your need. I would be happy to discuss and troubleshoot with you; contact me at &lt;a href="//mailto:contact@rohitfarmer.dev"&gt;contact@rohitfarmer.dev&lt;/a&gt;. Any suggestions to augment this protocol with more advanced features are welcomed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SSH to the HPC.&lt;/li&gt;
&lt;li&gt;Claim an interactive node (follow the standard procedure for your HPC, in my case it is &lt;code&gt;qrsh&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Note the interactive node name.&lt;/li&gt;
&lt;li&gt;Run Jupyter on the claimed interactive node by &lt;code&gt;jupyter notebook --no-browser --ip='0.0.0.0'&lt;/code&gt; or create an alias in your bashrc for a shortcut. For example &lt;code&gt;alias jup='jupyter notebook --no-browser --ip='0.0.0.0''&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On your computer start another SSH session with tunnelling using the interactive node name as noted above &lt;code&gt;ssh user@host -L8888:nodeName:8888 -N&lt;/code&gt;. &lt;em&gt;The prompt probably won’t return and you may also not see any message in your terminal, but as long as there is no error message, it’s probably running fine.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;To avoid re-writing the code in step 5 every time you tunnel you can use the shell script below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I named it &lt;code&gt;jupssh&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh

# Check if the arugment is passed.
if [[$# -eq 0]];
then
    echo 'Usage: jupssh &amp;lt;node name&amp;gt;'
    exit 1
fi

ssh user@host -L8888:$1:8888 -N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Copy the URL that the Jupyter daemon has generated in step 4 and paste it in the browser on your computer. URL should look something similar to &lt;code&gt;http://(nodeName or 127.0.0.1):8888/?token=3f7c3a8949b3fa1961c63653873fea075a93a29bffe373b5&lt;/code&gt;. Choose either nodeName or 127.0.0.1 in the URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Top banner photo by &lt;br&gt;
&lt;a href="https://unsplash.com/@fedechanw?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge" rel="noopener noreferrer" title="Download free do whatever you want high-resolution photos from Federica Galli"&gt;&lt;span&gt;unsplash-logo&lt;/span&gt;&lt;span&gt;Federica Galli&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>jupyter</category>
      <category>hpc</category>
      <category>supercomputing</category>
    </item>
    <item>
      <title>Learning R: Rant 1</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Wed, 17 Apr 2019 19:44:08 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/learning-r-rant-1-3n04</link>
      <guid>https://dev.to/rohitfarmer/learning-r-rant-1-3n04</guid>
      <description>&lt;p&gt;I learned machine learning and data science last year with Python in my previous job, and this year I am more or less doing the same stuff in R for my current job. Learning R seems to be a pain right now, because to me coming from Python R appears to be a giant mess. There is n number of packages with multiple of them doing more or less the same thing. For example, right now I am learning about data frames/tables in R. So you have traditional R data frames that are not very easy to work with. Therefore, there is an enhanced version of it in the form of data.tables(). Former generates a data frame and the later generates a data table. In addition to the data frame and table, there is something else called tibble that is produced by the packages in the tidyverse library. Why there is not just one package like Pandas for data frames and Numpy for nd arrays?&lt;/p&gt;

</description>
      <category>r</category>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>lifescience</category>
    </item>
    <item>
      <title>One Year of Doing Data Science &amp; Deep Learning</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Thu, 07 Feb 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/one-year-of-doing-data-science-amp-deep-learning-39ip</link>
      <guid>https://dev.to/rohitfarmer/one-year-of-doing-data-science-amp-deep-learning-39ip</guid>
      <description>&lt;p&gt;For the past year, I have been doing data science (DS) &amp;amp; deep learning (DL) to understand drug bioactivation, toxicity and their implications on drug-induced liver injuries (DILI). I come from a background of molecular modeling which is a computational approach to analyse molecules, but I would not consider it to be DS or DL. Since, DS and DL were a new subject that I picked up to master, this blog post is an account of my year-long journey.&lt;/p&gt;

&lt;p&gt;During my wait for the VISA to be sanctioned for my current position I asked my employer if there is anything that I should learn that would help me to get a good start in deep learning. The answer was Keras or Tensorflow that runs on Python. Ok, so I learned rudimentary Keras and Tensorflow and built intermediate level expertise in Python programming language. However, if someone wants to learn DL and if all he knows is vanilla Python programming then probably Keras or Tensorflow is not the first place to start. Most of the time in a DL project is spent in data wrangling which means getting the input data in the right format to be represented to a DL algorithm and re-formating the DL output for inference.&lt;/p&gt;

&lt;p&gt;Therefore, in my opinion, an excellent place to start is to learn how to use data handling and manipulation libraries such as Numpy and Pandas. These are the two most crucial tools that you would use in any DL project. Next, learning Matplotlib would help you to plot graphs for your input data and results. You can always use a code editor to practice these tools, but nothing beats Jupyter notebook. In Jupyter you can write markdown notes as you learn, execute small snippets of code in individual cells and also plot graphs in the same space. It is suitable for trying and testing code especially during the data wrangling stage as it allows you to visualize Numpy and Pandas data frames effectively as you go.&lt;/p&gt;

&lt;p&gt;Once you have mastered Numpy, Pandas, and Matplotlib familiarizing yourself with Scipy and Scikit-Learn is highly recommended. They are two general purpose data science and machine learning libraries that come very handy for various purposes during a DL project. I use them more often than Keras or Tensorflow. Some of the uses are for data scaling, creating train-test splits, generating stratified folds for cross-validations, metrics like ROC-AUC, MSE, MAE, etc., feature selection, statistical tests amongst others.&lt;/p&gt;

&lt;p&gt;In my opinion, these are the bare minimum tools you need to facilitate your DL project in addition to the main DL libraries such as Keras or Tensorflow. If you want to add a few extra feathers in your cap, I can recommend learning Seaborn and Plotly for graphs and plots. They are based on Matplotlib, but with enhanced features. Pyarrow Parquet a library that can take advantage of Parquet format for columnar data storage. On occasions, I have also used Stats Model library for some conventional statistical procedures.&lt;/p&gt;

&lt;p&gt;Now, coming to Keras and Tensorflow people usually start with Keras which is a higher level abstraction API for several DL engines including Tensorflow because of its ease. However, learning Tensorflow itself has a lot of incentives. Tensorflow gives you a lot more control over what you can do with your DL algorithm. Keras is undoubtedly the right place to start and is also very good for prototyping and also very suitable for many projects that can be solved using off the shelf DL procedures. However, if you are picking up DL for a long run, then Tensorflow would be inevitable.&lt;/p&gt;

&lt;p&gt;If you are a person like me who has come from a non-programming background, then you would also like to learn some additional tools that are part of any professional programmer’s toolbox. Probably nothing is more important than a version control system (VCS). At the moment I guess the two most widely used VCSs are Git and Mercurial. They both can be installed on your local machine or can be used in the cloud. Bitbucket supports both Git and Mercurial repositories, and GitHub supports git. Having a GitHub profile is not only good for keeping track of your programmes, but they also serve as a code portfolio that you can showcase during a job interview, etc. At this point, I should even mention my favorite code editor that is Microsoft Visual Studio Code. It’s free, cross-platform, officially supports Python and GitHub integration.&lt;/p&gt;

&lt;p&gt;The last piece of advice DL is only as useful as your domain knowledge in the subject that you are trying to study. DL is not going to magically find out answers for you if you are not asking the right question and providing it the correct data to look into.&lt;/p&gt;

&lt;p&gt;Top Banner Photo by &lt;a href="https://unsplash.com/@thefredyjacob?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge"&gt;unsplash-logo&lt;br&gt;
Fredy Jacob&lt;/a&gt; on Unsplash&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>deeplearning</category>
      <category>pandas</category>
    </item>
    <item>
      <title>How to use docker to run multiple neo4j servers simultaneously</title>
      <dc:creator>Rohit Farmer</dc:creator>
      <pubDate>Sun, 19 Aug 2018 23:00:00 +0000</pubDate>
      <link>https://dev.to/rohitfarmer/how-to-use-docker-to-run-multiple-neo4j-servers-simultaneously-3cmo</link>
      <guid>https://dev.to/rohitfarmer/how-to-use-docker-to-run-multiple-neo4j-servers-simultaneously-3cmo</guid>
      <description>&lt;p&gt;Neo4J graph database server can only mount one database at a time. To run more than one instances of the neo4j server with different databases mounted on them one of the efficient methods is to use &lt;a href="https://hub.docker.com/_/neo4j/" rel="noopener noreferrer"&gt;neo4j docker image&lt;/a&gt;. The key to using more than one neo4j servers simultaneously is to use different ports for http, https and bolt connections which is relatively easy to do with the docker image. For my purpose, I also had to configure neo4j in such a way that it can access the database from a non-default location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Installing the neo4j docker image.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Presuming that you already have docker installed and also that you are working in Linux environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull neo4j
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Running neo4j docker image.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
By default, the neo4j docker image mounts the following folders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /var/lib/neo4j/logs
plugins: /var/lib/neo4j/plugins
import: /import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These directories may correspond to the already existing directories on your system. In my case, I already had a neo4j community server running on my machine so all these locations were there and were being used by the server. Therefore, I had to provide a custom location that would provide the same information. These locations would not be there in your computer if you have not installed the server version and only intending to use the docker image. To my knowledge the most import of the above-mentioned folders are data this is where your actual database will be created/stored, import to put for example CSV files for import, conf to put neo4j.conf file.&lt;/p&gt;

&lt;p&gt;The command below is going to run the neo4j docker image taking care of running the server on non-default ports and also creating or mounting the required folders from the desired location.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --detach --name=my-neo4j --rm --env=NEO4J_AUTH=none \
--publish=7475:7474 --publish=7476:7473 --publish=7688:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/import:/import \
--volume=$HOME/neo4j/conf:/conf \
neo4j
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Breaking down the above-mentioned command.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;docker run …… neo4j is to run the neo4j docker image.&lt;br&gt;&lt;br&gt;
–detach to run the container in the background and return the prompt.&lt;br&gt;&lt;br&gt;
–name=my-neo4j to give the desired name to the docker instance otherwise docker will choose a random name which might not be very easy to remember if we want to refer to this session in future for some reason.&lt;br&gt;&lt;br&gt;
–rm is to delete the docker instance from the list upon session termination. This is useful if we want to reuse the same name.&lt;br&gt;&lt;br&gt;
–env=NEO4J_AUTH=none to set up the environment for no password login to the neo4j database.&lt;br&gt;&lt;br&gt;
–publish=7475:7474 –publish=7476:7473 –publish=7688:7687 to publish/forward the default http, https and bolt ports to the desired ports. In this case, the http, https and bolt ports will be forwarded to the desired 7475, 7476 and 7687 respectively.&lt;br&gt;&lt;br&gt;
–volume=$HOME/neo4j/data:/data \&lt;br&gt;&lt;br&gt;
–volume=$HOME/neo4j/import:/import \&lt;br&gt;&lt;br&gt;
–volume=$HOME/neo4j/conf:/conf \&lt;br&gt;&lt;br&gt;
to mount the desired locations for the database creation or access.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If you are running this command for the first time, it will create the folders mentioned in –volume tag. Otherwise, it will mount the existing folders to the neo4j docker defaults.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If no error is returned then your neo4j server is running and should have been mapped to the desired ports and folders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3. Check the docker and neo4j server running status.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
To check the current running docker session(s).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should give you an output something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1afa157d9caa neo4j "/sbin/tini -g -- ..." 36 minutes ago Up 36 minutes 7473/tcp, 0.0.0.0:7475-&amp;gt;7474/tcp, 0.0.0.0:7688-&amp;gt;7687/tcp my-neo4j
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To terminate this session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker kill my-neo4j
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check neo4j running status: open a web browser and then navigate to&lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:7475" rel="noopener noreferrer"&gt;http://localhost:7475&lt;/a&gt; (or the port that you have used for forwarding in step 2)&lt;/p&gt;

&lt;p&gt;It should render you a page like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frohitfarmer.github.io%2Fimages%2Fneo4j-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frohitfarmer.github.io%2Fimages%2Fneo4j-1.png" alt="Neo4j Login Page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Change the bolt port to 7688 (or the port that you have used for forwarding in step 2), leave the password field empty (as we have asked for no authentication in step 2) and click connect.&lt;/p&gt;

&lt;p&gt;It should connect you to your default graph.db database which should look something like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frohitfarmer.github.io%2Fimages%2Fneo4j-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frohitfarmer.github.io%2Fimages%2Fneo4j-2.png" alt="Neo4j Connection Established"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>neo4j</category>
      <category>graphdatabase</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
