Skip to content

Commit e9247e9

Browse files
authored
Merge pull request #1 from nodestream-proj/intial-version
Implement Connector
2 parents 45ce2a0 + e432b7b commit e9247e9

38 files changed

+5809
-0
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#This is used to automatically add reviewers to PR's. Developers can still manually add reviewers in addition to the below users.
2+
3+
* @zprobst @ccloes

.github/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing
2+
3+
Review our Contributing Guide [in the Docs](https://nodestream-proj.github.io/nodestream/contributing).
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: bug
6+
assignees: zprobst
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Additional context**
24+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[REQUEST]"
5+
labels: enhancement
6+
assignees: zprobst
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
15+
python-version: ["3.10", "3.11"]
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Install poetry
19+
run: pipx install poetry
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: 'poetry'
25+
- name: Install Dependencies
26+
run: |
27+
pip install --upgrade pip
28+
pip install --upgrade setuptools
29+
poetry env use ${{ matrix.python-version }}
30+
poetry install
31+
- name: Run Tests
32+
run: poetry run pytest --cov nodestream_plugin_neo4j --cov-report term --cov-report xml -m "not e2e"
33+
- name: Run Lints
34+
run: |
35+
poetry run ruff nodestream_plugin_neo4j tests
36+
poetry run black nodestream_plugin_neo4j tests --check
37+
poetry run isort nodestream_plugin_neo4j tests --check-only
38+
- name: Run E2E Tests
39+
run: poetry run pytest -m "e2e"
40+
if: "runner.os == 'Linux'"
41+
- name: Upload coverage reports to Codecov
42+
uses: codecov/codecov-action@v3
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
flags: ${{ matrix.python-version }}-${{ matrix.os }}

.gitignore

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"."
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
SHELL := /bin/bash
2+
3+
.PHONY: setup
4+
setup: venv lint test-unit
5+
6+
.PHONY: clean-pyc
7+
clean-pyc:
8+
find . -name '*.pyc' -exec rm -rf {} +
9+
find . -name '*.pyo' -exec rm -rf {} +
10+
find . -name '*~' -exec rm -rf {} +
11+
find . -name '__pycache__' -exec rm -rf {} +
12+
13+
.PHONY: clean-test
14+
clean-test:
15+
rm -rf .pytest_cache
16+
rm -rf .mypy_cache
17+
rm -rf .coverage
18+
rm -rf .reports
19+
rm -rf htmlcov/
20+
rm -rf .pytest_cache
21+
22+
.PHONY: clean
23+
clean: clean-pyc clean-test
24+
25+
venv: poetry.lock
26+
poetry install
27+
28+
.PHONY: format
29+
format: venv
30+
poetry run black nodestream_plugin_neo4j tests
31+
poetry run isort nodestream_plugin_neo4j tests
32+
33+
.PHONY: lint
34+
lint: venv
35+
poetry run black nodestream_plugin_neo4j tests --check
36+
poetry run ruff nodestream_plugin_neo4j tests
37+
38+
.PHONY: test-unit
39+
test-unit: venv
40+
poetry run pytest -m "not e2e"
41+
42+
.PHONY: test-e2e
43+
test-e2e: venv
44+
poetry run pytest -m "e2e"
45+
46+
.PHONY: docs-build
47+
docs-build: venv
48+
poetry run mkdocs build
49+
50+
.PHONY: docs-server
51+
docs-server: venv
52+
poetry run mkdocs serve
53+
54+
.PHONY: snapshot
55+
snapshot: venv
56+
poetry run pytest --snapshot-update
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .database_connector import Neo4jDatabaseConnector
2+
3+
__all__ = ("Neo4jDatabaseConnector",)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from nodestream.databases import DatabaseConnector, TypeRetriever
2+
from nodestream.databases.query_executor import QueryExecutor
3+
from nodestream.schema.migrations import Migrator
4+
5+
from .ingest_query_builder import Neo4jIngestQueryBuilder
6+
from .migrator import Neo4jMigrator
7+
from .neo4j_database import Neo4jDatabaseConnection
8+
from .query_executor import Neo4jQueryExecutor
9+
from .type_retriever import Neo4jTypeRetriever
10+
11+
12+
class Neo4jDatabaseConnector(DatabaseConnector, alias="neo4j"):
13+
"""A Connector for Neo4j Graph Databases.
14+
15+
This class is responsible for creating the various components needed for
16+
nodestream to interact with a Neo4j database. It is also responsible
17+
for providing the configuration options for the Neo4j database.
18+
"""
19+
20+
@classmethod
21+
def from_file_data(
22+
cls,
23+
use_enterprise_features: bool = False,
24+
use_apoc: bool = True,
25+
**connection_args
26+
):
27+
database_connection = Neo4jDatabaseConnection.from_configuration(
28+
**connection_args
29+
)
30+
return cls(
31+
database_connection=database_connection,
32+
use_enterprise_features=use_enterprise_features,
33+
use_apoc=use_apoc,
34+
)
35+
36+
def __init__(
37+
self,
38+
database_connection: Neo4jDatabaseConnection,
39+
use_apoc: bool,
40+
use_enterprise_features: bool,
41+
) -> None:
42+
self.use_enterprise_features = use_enterprise_features
43+
self.use_apoc = use_apoc
44+
self.database_connection = database_connection
45+
46+
def make_query_executor(self) -> QueryExecutor:
47+
query_builder = Neo4jIngestQueryBuilder(self.use_apoc)
48+
return Neo4jQueryExecutor(self.database_connection, query_builder)
49+
50+
def make_type_retriever(self) -> TypeRetriever:
51+
return Neo4jTypeRetriever(self.database_connection)
52+
53+
def make_migrator(self) -> Migrator:
54+
return Neo4jMigrator(self.database_connection, self.use_enterprise_features)

0 commit comments

Comments
 (0)