Skip to content

Commit

Permalink
Merge branch 'rc/0.1.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusconjeaud authored May 21, 2024
2 parents ba8985d + 4bb69d2 commit fee29b6
Show file tree
Hide file tree
Showing 22 changed files with 294 additions and 209 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Integration tests

on:
push:
branches: [ "master", "rc/**" ]
pull_request:
branches: [ "master", "rc/**" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8", "3.7"]
neo4j-version: ["community", "4.4-community"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Creating Neo4j Container
run: |
chmod +x ./scripts/docker-neo4j.sh
sh ./scripts/docker-neo4j.sh ${{ matrix.neo4j-version }}
sleep 30s
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Test with pytest
run: |
export DJANGO_SETTINGS_MODULE=settings
tests/manage.py install_labels
tests/manage.py migrate
pytest
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ development.env
.ropeproject
\#*\#
tests/test.db
.DS_Store
.DS_Store
.vscode
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

17 changes: 17 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
Version 0.1.2 2024-05
* Bump neomodel to 5.3.0

Version 0.1.1 2023-08
* Bump neomodel to 5.1.0 - full support of Neo4j version 5.x (and 4.4 LTS)
* Support higher versions of Django (> 2.2)

Version 0.1.0 2023-04
* Upgrade neomodel dependency to version 5.0.0
* Adds support for all Neo4j 5.x versions, and 4.4 (LTS)
* Drops support of Neo4j version 4.3 and under

Version 0.0.8 2023-03
* Upgrade neomodel dependency to version 4.0.10
* Adds support for all Neo4j 4.x versions
* Adds support for Python up to 3.11

Version 0.0.7 2021-07-06
* Added Docker Example
* Django admin regsister for nodes is now available (beta)
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.rst
include README.md
include AUTHORS.txt
include Changelog
include LICENSE
105 changes: 39 additions & 66 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
Django Neomodel (beta!)
=======================
# Django Neomodel (beta!)

.. image:: https://raw.githubusercontent.com/robinedwards/neomodel/master/doc/source/_static/neomodel-300.png
:alt: neomodel
![neomodel](https://raw.githubusercontent.com/neo4j-contrib/neomodel/master/doc/source/_static/neomodel-300.png)

This module allows you to use the neo4j_ graph database with Django using neomodel_
This module allows you to use the [neo4j](https://www.neo4j.org) graph database with Django using [neomodel](http://neomodel.readthedocs.org)

.. _neo4j: https://www.neo4j.org
.. _neomodel: http://neomodel.readthedocs.org

.. image:: https://secure.travis-ci.org/neo4j-contrib/django-neomodel.png
:target: https://secure.travis-ci.org/neo4j-contrib/django-neomodel/
## Warnings

Warnings
=======================
* Admin functionality is very experimental. [Please see todos / issues here](https://github.com/neo4j-contrib/django-neomodel/projects/1)

* Admin functionality is very experimental. `Please see todos / issues here <https://github.com/neo4j-contrib/django-neomodel/projects/1>`_
## Live Examples (add yours here)

Live Examples (add yours here)
=======================
* [Syracuse](https://syracuse.1145.am>): a database of company linkages created from unstructured text. Repo at [syracuse-neo](https://github.com/alanbuxton/syracuse-neo.git)

* `ResoTrack <https://resotrack.herokuapp.com/>`_
# Getting started

Getting started
===============

Install the module::
Install the module:

$ pip install django_neomodel

Add the following settings to your `settings.py`::
Add the following settings to your `settings.py`:

NEOMODEL_NEO4J_BOLT_URL = os.environ.get('NEO4J_BOLT_URL', 'bolt://neo4j:test@localhost:7687')
NEOMODEL_NEO4J_BOLT_URL = os.environ.get('NEO4J_BOLT_URL', 'bolt://neo4j:foobarbaz@localhost:7687')

# Make sure django_neomodel comes before your own apps
INSTALLED_APPS = (
Expand All @@ -40,7 +30,7 @@ Add the following settings to your `settings.py`::
'yourapp'
)

Write your first node definition in `yourapp/models.py`::
Write your first node definition in `yourapp/models.py`:

from neomodel import StructuredNode, StringProperty, DateProperty

Expand All @@ -49,18 +39,18 @@ Write your first node definition in `yourapp/models.py`::
published = DateProperty()

Create any constraints or indexes for your labels. This needs to be done after you change your node definitions
much like `manage.py migrate`::
much like `manage.py migrate`:

$ python manage.py install_labels

Now in a view `yourapp/views.py`::
Now in a view `yourapp/views.py`:

from .models import Book

def get_books(request):
return render('yourapp/books.html', request, {'books': Book.nodes.all()})

In your `yourapp/admin.py`::
In your `yourapp/admin.py`:

from django_neomodel import admin as neo_admin
from .models import Book
Expand All @@ -71,10 +61,9 @@ In your `yourapp/admin.py`::

And you're ready to go. Don't forget to check the neomodel_ documentation.

Model forms
===========
## Model forms

Switch the base class from `StructuredNode` to `DjangoNode` and add a 'Meta' class::
Switch the base class from `StructuredNode` to `DjangoNode` and add a 'Meta' class:

from datetime import datetime
from django_neomodel import DjangoNode
Expand All @@ -93,7 +82,7 @@ Switch the base class from `StructuredNode` to `DjangoNode` and add a 'Meta' cla
class Meta:
app_label = 'library'

Create a model form class for your `DjangoNode`::
Create a model form class for your `DjangoNode`:

class BookForm(ModelForm):
class Meta:
Expand All @@ -102,19 +91,17 @@ Create a model form class for your `DjangoNode`::

This class may now be used just like any other Django form.

Settings
========
## Settings
The following config options are available in django settings (default values shown).
These are mapped to neomodel.config as django is started::
These are mapped to neomodel.config as django is started:

NEOMODEL_NEO4J_BOLT_URL = 'bolt://neo4j:neo4j@localhost:7687'
NEOMODEL_SIGNALS = True
NEOMODEL_FORCE_TIMEZONE = False
NEOMODEL_MAX_CONNECTION_POOL_SIZE = 50

Signals
=======
Signals work with `DjangoNode` sub-classes::
## Signals
Signals work with `DjangoNode` sub-classes:

from django.db.models import signals
from django_neomodel import DjangoNode
Expand All @@ -131,10 +118,9 @@ Signals work with `DjangoNode` sub-classes::
The following are supported: `pre_save`, `post_save`, `pre_delete`, `post_delete`.
On freshly created nodes `created=True` in the `post_save` signal argument.

Testing
=======
## Testing

You can create a setup method which clears the database before executing each test::
You can create a setup method which clears the database before executing each test:

from neomodel import db, clear_neo4j_database

Expand All @@ -145,14 +131,12 @@ You can create a setup method which clears the database before executing each te
def test_something(self):
pass

Management Commands
===================
## Management Commands

The following django management commands have been included.

install_labels
--------------
Setup constraints and indexes on labels for your node definitions. This should be executed after any schema changes::
### install_labels
Setup constraints and indexes on labels for your node definitions. This should be executed after any schema changes:

$ python manage.py install_labels
Setting up labels and constraints...
Expand All @@ -161,27 +145,19 @@ Setup constraints and indexes on labels for your node definitions. This should b
+ Creating unique constraint for title on label Book for class tests.someapp.models.Book
Finished 1 class(es).

clear_neo4j
-----------
### clear_neo4j
Delete all nodes in your database, warning there is no confirmation!

Requirements
============

- Python 3.6+
- neo4j 3.5+

.. image:: https://badges.gitter.im/Join%20Chat.svg
:alt: Join the chat at https://gitter.im/robinedwards/neomodel
:target: https://gitter.im/robinedwards/neomodel?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
## Requirements

Docker Example
===================
- Python 3.7+
- neo4j 5.x, 4.4 (LTS)

## Docker Example

Using Docker Compose.

Commands to setup Docker Container docker-entrypoint.sh::
Commands to setup Docker Container docker-entrypoint.sh:

# Go to tests
$ cd tests/
Expand All @@ -194,19 +170,16 @@ Go to http://localhost:7474/browser/
Go to http://localhost:8000/admin/


Running Tests
===================
## Running Tests

Setup Neo4j Desktop with a local database with password 'foobar' and version 4.1.2 (current version when this was written).
Setup Neo4j Desktop with a local database with password 'foobarbaz' and version 5.x or 4.4.x (Neo4j LTS version).

Commands to run tests::
Commands to run tests:

# create local venv and install dependencies.
$ python3 -m venv venv; source venv/bin/activate; python setup.py develop; export DJANGO_SETTINGS_MODULE=tests.settings;
# Go to tests
$ cd tests/
$ ./manage.py install_labels
$ ./manage.py migrate
$ pip install -e '.[dev]'; export DJANGO_SETTINGS_MODULE=tests.settings;
$ tests/manage.py install_labels
$ tests/manage.py migrate
$ pytest

# example output:
Expand Down
Loading

0 comments on commit fee29b6

Please sign in to comment.