<commit_before>#!/bin/bash
set -o errexit; # Fail build on first error, instead of carrying on by default

if [ -z "$REPO_DIR" ]; then
  echo "REPO_DIR is not set. Please run source tools/initenv.sh first";
  exit 1;
fi

if [ -z "$1" ]; then
  echo "Please specify the path to a notebook (.ipynb).";
  exit 1;
fi

# Load the common build config
source $REPO_DIR/sources/server/config.sh;

# Install NodeJS server dependencies
npm install --prefix "$build_path";

storage_root=`dirname "$1"`
notebook_relative_path=`basename $1`;

# Start the DataLab NodeJS server.
node "$build_path/server.js" -n "$storage_root" &
# Capture the server process id so that we can kill it later.
server_pid=$!;

# Wait a moment for server to start before opening a connection.
sleep 1;
echo "Opening notebook $notebook_relative_path";

notebook_url="http://localhost:9000/#/notebooks/$notebook_relative_path";

# Open the default browser to the specified notebook path
echo "Opening your browser to notebook: $notebook_url"
os=`uname`;
if [ "$os" == "Darwin" ]; then
  open "$notebook_url"
else # Assume Linux
  xdg-open "$notebook_url"
fi

# When the user presses Ctrl-C, kill the node server process before exitting.
trap handle_interrupt INT
function handle_interrupt() {
  kill $server_pid;
  echo "Thanks for trying DataLab!";
}

# Don't exit script unless the node server process dies.
wait $server_pid;
<commit_msg>Fixes launcher script so that it always specifies a storage root directory even when an ipynb is opened directly<commit_after>#!/bin/bash
set -o errexit; # Fail build on first error, instead of carrying on by default

if [ -z "$REPO_DIR" ]; then
  echo "REPO_DIR is not set. Please run source tools/initenv.sh first";
  exit 1;
fi

if [ -z "$1" ]; then
  echo "Please specify the path to a notebook (.ipynb).";
  exit 1;
fi

# Load the common build config
source $REPO_DIR/sources/server/config.sh;

# Install NodeJS server dependencies
npm install --prefix "$build_path";

storage_root=`dirname "$1"`;
notebook_relative_path=`basename $1`;

# Start the DataLab NodeJS server.
node "$build_path/server.js" -n "$PWD/$storage_root" &
# Capture the server process id so that we can kill it later.
server_pid=$!;

# Wait a moment for server to start before opening a connection.
sleep 1;
echo "Opening notebook $notebook_relative_path";

notebook_url="http://localhost:9000/#/notebooks/$notebook_relative_path";

# Open the default browser to the specified notebook path
echo "Opening your browser to notebook: $notebook_url"
os=`uname`;
if [ "$os" == "Darwin" ]; then
  open "$notebook_url"
else # Assume Linux
  xdg-open "$notebook_url"
fi

# When the user presses Ctrl-C, kill the node server process before exitting.
trap handle_interrupt INT
function handle_interrupt() {
  kill $server_pid;
  echo "Thanks for trying DataLab!";
}

# Don't exit script unless the node server process dies.
wait $server_pid;

{'fraction_non_alphanumeric': 0.10340089316386121, 'fraction_numerical': 0.006870491240123669, 'mean_word_length': 4.621621621621622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192043', 'n_tokens_mistral': 952, 'n_tokens_neox': 916, 'n_words': 360}