{ "cells": [ { "cell_type": "markdown", "id": "94cb93cf", "metadata": {}, "source": [ "## Bulk Load to Neptune " ] }, { "cell_type": "markdown", "id": "55819d1c", "metadata": {}, "source": [ "We use the `%load` magic command which is available as part of the AWS `graph-notebook` to bulk load data to our Neptune database. You can use the `%graph_notebook_config` magic command to see information about the Neptune cluster associated with your graph-notebook, and `%status` magic command to see the status of your Neptune cluster.\n", "\n", "Note: Use [these CloudFormation templates](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-quick-start.html) to quickly spin up a `graph-notebook`, an associted Neptune cluster, and set up all the configurations needed to work with Neptune ML in a `graph-notebook`." ] }, { "cell_type": "code", "execution_count": null, "id": "7c7238e4", "metadata": {}, "outputs": [], "source": [ "import sagemaker\n", "\n", "sess = sagemaker.Session()\n", "bucket = sess.default_bucket()\n", "bucket = bucket #''\n", "prefix = 'fake-news-detection/data'" ] }, { "cell_type": "code", "execution_count": null, "id": "8a30208e", "metadata": {}, "outputs": [], "source": [ "s3_uri = f\"s3://{bucket}/{prefix}\"" ] }, { "cell_type": "code", "execution_count": null, "id": "c050f0eb", "metadata": {}, "outputs": [], "source": [ "%status" ] }, { "cell_type": "code", "execution_count": null, "id": "732e0a70", "metadata": {}, "outputs": [], "source": [ "%load -s {s3_uri} -f csv -p OVERSUBSCRIBE --run" ] }, { "cell_type": "markdown", "id": "5c618610", "metadata": {}, "source": [ "Once the above cell has completed, the data has been loaded into the cluster. We verify the data loaded correctly by running the traversals below to see the count of nodes and edges by label:" ] }, { "cell_type": "code", "execution_count": null, "id": "45f1d6e4", "metadata": {}, "outputs": [], "source": [ "%%gremlin\n", "g.V().groupCount().by(label).unfold().order().by(keys)" ] }, { "cell_type": "code", "execution_count": null, "id": "05dfec12", "metadata": {}, "outputs": [], "source": [ "%%gremlin\n", "g.E().groupCount().by(label).unfold().order().by(keys)" ] }, { "cell_type": "code", "execution_count": null, "id": "f15c0d23", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.12" } }, "nbformat": 4, "nbformat_minor": 5 }