Skip to content

Commit

Permalink
NetworkX and Pandas are optional dependencies for experimental tools
Browse files Browse the repository at this point in the history
  • Loading branch information
JackAtOmenApps committed Feb 26, 2021
1 parent 86efc22 commit 9e859ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ Currently, it provides numerous methods for retrieving nodes, and a few for retr

[Quickstart example](https://django-postgresql-dag.readthedocs.io/en/latest/quickstart.html)

## Install

pip install django-postgresql-dag

With optional dependencies for using transformations:

pip install django-postgresql-dag[transforms]


## ToDo

Expand All @@ -29,4 +37,3 @@ Currently, it provides numerous methods for retrieving nodes, and a few for retr
2. [django-dag](https://pypi.org/project/django-dag/)
3. [django-dag-postgresql](https://github.com/worsht/django-dag-postgresql)
4. [django-treebeard-dag](https://pypi.org/project/django-treebeard-dag/)

14 changes: 9 additions & 5 deletions django_postgresql_dag/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
django-postgresql-dag to alternate formats.
"""

from itertools import chain

import networkx as nx
import pandas as pd
from django.core.exceptions import FieldDoesNotExist
from django.db.models import Case, When
from django.db.models.fields import DateTimeField, UUIDField
from django.db.models.fields.files import ImageField, FileField
from django.db.models.fields.files import FileField, ImageField
from django.db.models.fields.related import ManyToManyField

from .exceptions import GraphModelsCannotBeParsedException, IncorrectUsageException

from itertools import chain
import networkx as nx
from .exceptions import (GraphModelsCannotBeParsedException,
IncorrectUsageException)


def _ordered_filter(queryset, field_names, values):
Expand Down Expand Up @@ -203,6 +205,8 @@ def nx_from_queryset(
graph_attributes_dict: A dictionary of attributes to add to the graph itself
node_attribute_fields_list: a list of strings of field names to be added to nodes
edge_attribute_fields_list: a list of strings of field names to be added to edges
date_strf: if any provided fields are date-like, how should they be formatted?
digraph: bool to determine whether to output a directed or undirected graph
"""
_NodeModel, _EdgeModel, queryset_type = get_queryset_characteristics(queryset)

Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@
classifiers=classifiers,
long_description_content_type="text/markdown",
long_description=long_desc,
extras_require = {
'transforms': ['networkx>=2.5', 'pandas>=1.2']
}
)

0 comments on commit 9e859ab

Please sign in to comment.