Book Image

Julia 1.0 Programming Cookbook

By : Bogumił Kamiński, Przemysław Szufel
Book Image

Julia 1.0 Programming Cookbook

By: Bogumił Kamiński, Przemysław Szufel

Overview of this book

Julia, with its dynamic nature and high-performance, provides comparatively minimal time for the development of computational models with easy-to-maintain computational code. This book will be your solution-based guide as it will take you through different programming aspects with Julia. Starting with the new features of Julia 1.0, each recipe addresses a specific problem, providing a solution and explaining how it works. You will work with the powerful Julia tools and data structures along with the most popular Julia packages. You will learn to create vectors, handle variables, and work with functions. You will be introduced to various recipes for numerical computing, distributed computing, and achieving high performance. You will see how to optimize data science programs with parallel computing and memory allocation. We will look into more advanced concepts such as metaprogramming and functional programming. Finally, you will learn how to tackle issues while working with databases and data processing, and will learn about on data science problems, data modeling, data analysis, data manipulation, parallel processing, and cloud computing with Julia. By the end of the book, you will have acquired the skills to work more effectively with your data
Table of Contents (18 chapters)
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Index

Running Julia inside the Cloud9 IDE in the AWS cloud


Cloud9 is an integrated programming environment that can be run inside a web browser. We will demonstrate how to configure this environment for programming with Julia. The web page of Cloud9 can be reached at https://aws.amazon.com/cloud9/.

Getting ready

In order to use Cloud9, you must have an active Amazon Web Services (AWS) account and log in to the AWS management console.

Cloud9 can create a new EC2 instance running Amazon Linux or can connect to any existing Linux server that allows SSH connections and has Node.js installed.In order to start working with Julia on Cloud9, complete the following steps:

  1. Prepare a Linux machine with Julia installed (you can follow the instructions in the previous sections).
  2. Install Node.js. In Ubuntu 18.04.1 LTS, for example, the only step needed is to runsudo apt install nodejs.
  3. Make sure that your server is accepting external SSH connections. For an AWS EC2 instance, you need to configure the instance security group to accept SSH connections from0.0.0.0/0—in order to do this, click on the EC2 instance in the AWS console, select Security Groups | Inbound | Edit, and add a new rule that accepts all traffic.

Note

In the GitHub repository for this recipe, you will find the JuliaRunner.run file that contains the configuration for the AWS Cloud9.

How to do it...

Once you have prepared a server with Julia and Node.js, you can take the following steps to use Cloud9:

  1. In the AWS console, go to the Cloud9 service and create a new environment.
  2. Select the Connect and run in remote server (SSH) option.
  3. For the username, typeubuntu if you use Ubuntu Linux, orec2-user if you are running Amazon Linux, CentOS, or Red Hat (please note that this recipe has been tested with Ubuntu).
  4. Provide the hostname (public DNS) of your EC2 instance.
  5. Configure SSH authorization.
  6. In the Environment settings screen, select Copy key to clipboard to copy the key.
  7. Open an SSH connection to your remote server in a Terminal window.
  8. Execute the nano ~/.ssh/authorized_keys command to edit the file.
  9. Create an empty line and paste the public key content that you have just copied.
  10. PressCtrl + Xand confirm the changes withYto exit.
  1. Now, you are ready to click the Next step button in the Cloud9 console. Cloud9 will connect to your server and automatically install all the required software. After a few minutes, you will see your Cloud9 IDE. By default, Cloud9 does not support running programs in Julia. 
  2. Go to the Run menu and select Run with | New runnerType the following contents:
 {
"cmd" : ["julia", "$file", "$args"],
"info" : "Started $project_path$file_name",
"selector" : "source.jl"
 }
  1. Save the file asJuliaRunner.run.
  2. Now, pressing the Run button will run your Julia *.jlfile.

Note

Please make sure that the Cloud9 folder points to/.c9/runners.

How it works...

The Cloud9 environment runs in your web browser. The browser opens a REST connection back to Cloud9's server, which in turn opens an SSH connection to your Linux instance (see the following diagram). This functionality will, in fact, run with any Linux server that accepts incoming connections from Cloud9 (more details on configuring other Linux servers with Cloud9 can be found at https://docs.aws.amazon.com/cloud9/latest/user-guide/ssh-settings.html):

 

Please note that this means that the EC2 instance supporting Cloud9 should allow incoming connections from the AWS Cloud9 infrastructure. In production environments, we recommend limiting traffic to the EC2 instance (viaSecurityGroup) to the IP ranges defined for Cloud9. Detailed instructions can be found in Cloud9's documentation: https://docs.aws.amazon.com/cloud9/latest/user-guide/ip-ranges.html.

See also

The Cloud9 environment is being continuously updated by AWS; new features are being added frequently. For the latest documentation, we recommend looking at AWS Cloud9's user guide, available athttps://docs.aws.amazon.com/cloud9/latest/user-guide/. In particular, it is worth looking athttps://docs.aws.amazon.com/cloud9/latest/user-guide/get-started.html.