Skip to content

Commit

Permalink
Port to github (#3)
Browse files Browse the repository at this point in the history
* Port to github.

- magic commands to connect to graph endpoints using gremlinpython for TinkerPop and SPARQLWrapper/requests for SPARQL
- magic commands for connecting to Neptune-specific api paths
- custom widget for visualizing graph results.
- premade starter notebooks to walk through notebook functionality
- seed datasets to load data into Tinkerpop or SPARQL for trying out graph

Co-authored-by: Austin Kline <austinkline@>
  • Loading branch information
austinkline authored Nov 2, 2020
1 parent 5e8fc66 commit 3096f23
Show file tree
Hide file tree
Showing 232 changed files with 213,815 additions and 7 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Bug report

about: Create a report to help us improve

title: "[BUG] Summarize the issue in a few words here"

labels: bug

assignees: 'austinkline'

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature request

about: Suggest an idea for this project

title: ''

labels: ''

assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
113 changes: 113 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Integration Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
generate-stack-name:
runs-on: ubuntu-latest
outputs:
stack-name: ${{ steps.generate-stack-name.outputs.stack-name }}
steps:
- name: Generate Stack Name
id: generate-stack-name
run: echo "::set-output name=stack-name::$(echo graph-notebook-$RANDOM)"
shell: bash
create-stack:
runs-on: ubuntu-latest
needs: generate-stack-name
steps:
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
role-session-name: IntegrationTestRunner
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install
run: |
pip install .
- name: Create Stack
id: create-stack
run: |
python test/integration/NeptuneIntegrationWorkflowSteps.py \
create-cfn-stack \
--cfn-stack-name ${{ needs.generate-stack-name.outputs.stack-name }} \
--cfn-template-url ${{ secrets.CFN_TEMPLATE_URL }} \
--cfn-s3-bucket ${{ secrets.INTEG_CFN_S3_BUCKET }} \
--cfn-runner-role ${{ secrets.CFN_ROLE }} \
--aws-region ${{ secrets.AWS_REGION }}
run-tests:
runs-on: ubuntu-latest
needs: [generate-stack-name, create-stack]
steps:
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
role-session-name: IntegrationTestRunner
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install
run: |
pip install .
- name: Give user /etc/hosts permission
run: |
sudo chmod 777 /etc/hosts
- name: Run Basic Tests
run: |
python test/integration/NeptuneIntegrationWorkflowSteps.py \
run-tests \
--pattern "*without_iam.py" \
--cfn-stack-name ${{ needs.generate-stack-name.outputs.stack-name }} \
--aws-region ${{ secrets.AWS_REGION }}
- name: Run Networkx Tests
run: |
python test/integration/NeptuneIntegrationWorkflowSteps.py \
run-tests \
--pattern "*network*.py" \
--cfn-stack-name ${{ needs.generate-stack-name.outputs.stack-name }} \
--aws-region ${{ secrets.AWS_REGION }}
- name: Run IAM Tests
run: |
python test/integration/NeptuneIntegrationWorkflowSteps.py \
run-tests \
--pattern "*with_iam.py" \
--iam \
--cfn-stack-name ${{ needs.generate-stack-name.outputs.stack-name }} \
--aws-region ${{ secrets.AWS_REGION }}
- name: Cleanup
run: |
python test/integration/NeptuneIntegrationWorkflowSteps.py \
delete-cfn-stack \
--cfn-stack-name ${{ needs.generate-stack-name.outputs.stack-name }} \
--aws-region ${{ secrets.AWS_REGION }}
31 changes: 31 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unit Tests

on: [push]

jobs:
unit-tests:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 ./test --max-complexity 10 --ignore E501,C901,W291 --show-source --statistics
- name: Install
run: |
pip install .
- name: Test with pytest
run: |
pytest
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# IDE directories
.vscode
.idea
**/.DS_Store

# python-generated directories
venv
**/__pycache__
.pytest_cache
src/graph_notebook.egg-info
**.pyc
build
dist

MANIFEST

# do not include widget typescript output directories
src/graph_notebook/widgets/dist/
src/graph_notebook/widgets/docs/
src/graph_notebook/widgets/labextension/
src/graph_notebook/widgets/nbextension/
src/graph_notebook/widgets/node_modules/
src/graph_notebook/widgets/lib/

# npm
node_modules/
node_modules/.package-lock.json
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reported the issue. Please try to include as much information as you can. Detail
## Contributing via Pull Requests
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:

1. You are working against the latest source on the *master* branch.
1. You are working against the latest source on the *main* branch.
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.

Expand Down
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
19 changes: 19 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include tsconfig.json
include package.json
include webpack.config.js
include src/graph_notebook/widgets/labextension/*.tgz

# Javascript files
graft graph_notebook/widgets/nbextension
graft graph_notebook/widgets/labextension
graft graph_notebook/widgets/src
graft graph_notebook/widgets/css
graft **/node_modules
prune coverage

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

94 changes: 88 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,97 @@
## My Project
## graph-notebook

TODO: Fill this README out!
Python package integrating jupyter notebooks with various graph-stores including
[Apache Tinkerpop](https://tinkerpop.apache.org/) and [RDF SPARQL](https://www.w3.org/TR/rdf-sparql-query/).

Be sure to:
## Requirements
- Python3.6
- Jupyter Notebooks

* Change the title in this README
* Edit your repository description on GitHub
## Installation

```
# install the package
pip install graph-notebook
# install and enable the visualization widget
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
# copy static html resources
python -m graph_notebook.static_resources.install
python -m graph_notebook.nbextensions.install
# copy premade starter notebooks
python -m graph_notebook.notebooks.install --destination /notebook/destination/dir
```

## Configuration

In order to connect to your graph database, you have three configuration options.

1. Change the host setting in your opened jupyter notebook by running the following in a notebook cell:

```
%graph_notebook_host you-endpoint-here
```

2. Change your configuration entirely grabbing the current configuration, making edits, and saving it to your notebook by running the following cells:

```
# 1. print your configuration
%graph_notebook_config
# default config will be printed if nothing else is set:
{
"host": "change-me",
"port": 8182,
"auth_mode": "DEFAULT",
"iam_credentials_provider_type": "ROLE",
"load_from_s3_arn": "",
"ssl": true,
"aws_region": "us-east-1"
}
# 2. in a new cell, change the configuration by using %%graph_notebook_config (note the two leading %% instead of one)
%%graph_notebook_config
{
"host": "changed-my-endpoint",
"port": 8182,
"auth_mode": "DEFAULT",
"iam_credentials_provider_type": "ENV",
"load_from_s3_arn": "",
"ssl": true,
"aws_region": "us-east-1"
}
```

3. Store a configuration under ~/graph_notebook_config.json
```
echo "{
"host": "changed-my-endpoint",
"port": 8182,
"auth_mode": "DEFAULT",
"iam_credentials_provider_type": "ENV",
"load_from_s3_arn": "",
"ssl": true,
"aws_region": "us-east-1"
}" >> ~/graph_notebook_config.json
```

## Authentication

If you are running a SigV4 authenticated endpoint, ensure that the config field `iam_credentials_provider_type` is set
to `ENV` and that you have set the following environment variables:

- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_REGION
- AWS_SESSION_TOKEN (OPTIONAL. Use if you are using temporary credentials)


## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
See [CONTRIBUTING](https://github.com/aws/graph-notebook/blob/main/CONTRIBUTING.md) for more information.

## License

Expand Down
Loading

0 comments on commit 3096f23

Please sign in to comment.