elpaso / django-dag Goto Github PK
View Code? Open in Web Editor NEWBasic portable Directed Acyclic Graph application for Django
Basic portable Directed Acyclic Graph application for Django
Django DAG ---------- Django-dag is a small reusable app which implements a Directed Acyclic Graph. Usage ..... Django-dag uses abstract base classes, to use it you must create your own concrete classes that inherit from Django-dag classes. The `dag_test` app contains a simple example and a unit test to show you its usage. Example:: class ConcreteNode(node_factory('ConcreteEdge')): """ Test node, adds just one field """ name = models.CharField(max_length = 32) class ConcreteEdge(edge_factory(ConcreteNode, concrete = False)): """ Test edge, adds just one field """ name = models.CharField(max_length = 32, blank = True, null = True) Tests ..... Unit tests can be run with just django installed at the base directory by running `python manage.py test`
https://github.com/elpaso/django-dag/blob/master/django_dag/models.py#L221
Should be:
node_model_name = node_model._meta.model_name
I would like to use this software in a commercial application but I can not because "Thus the GNU Affero GPL v3 stipulates that any adaptation of software that it covers must prominently offer its source code for download to users who interact with it over a network."
http://oss-watch.ac.uk/resources/agpl
Can you change the license to something less restrictive?
Django 1.8 yields a warning:
WARNINGS: units.UnitNode.children: (fields.W340) null has no effect on ManyToManyField.
I'm developing a package with Django 1.11 which depends on django-dag.
There are 2 models in the app depending on dag:
class BayesianNetworkEdge(
edge_factory('bayesian_networks.BayesianNetworkNode')):
....
class BayesianNetworkNode(
node_factory('bayesian_networks.BayesianNetworkEdge')):
....
The problem is that on a fresh install, django_dag does not ships with the initial migration and Django creates it when another migration requiring it is created.
If I ship that migration (pointing to django_dag tables) it will fail on a fresh install because it points to a non-existent one, and the migrations have to be deleted and recreated to trigger the creation of dag tables.
Have you consider including an initial migration with those tables in order to fix this kind of problems?
Thanks for merging my requests, do you think you could push the latest version to pypi?
Again, it would be nice, if you create a new version, containing Django 2.2 compatibility.
This isn't a bug or problem per se- but while doing some query optimizations in my project, I realized that the descendants_tree() (and I assume ancestor_tree and ans_set/des_set) command(s) uses a large number of queries to complete. I'm wondering if there is an easy way to cut down the number of queries for the nested structure. I had something in mind like a select_related() query that could at least cut down the number of db hits.
For now, the rest of my project is too important to overlook, so it may be a while until I can get back to it and work on a pull request.
Thanks for this project!
That would be nice.
Are duplicate child_id/parent_id pairs valid? Or should we apply a unique constraint to avoid adding the same child to the same parent more than once, as shown below:
bdipr=# select * from django_dag_edge;
id | child_id | parent_id
----+----------+-----------
1 | 1 | 2
2 | 1 | 2
(2 rows)
(ENV) rodrigo@enoch:~/code/pkgs/ckctr/django-ai/django_ai$ python manage.py migrate examples
System check identified some issues:
WARNINGS:
bayesian_networks.BayesianNetworkNode.children: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Apply all migrations: examples
Running migrations:
Applying examples.0004_bn_example...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/home/rodrigo/code/pkgs/ckctr/django-ai/django_ai/examples/migrations/0004_bn_example.py", line 57, in create_bn1_example
mu.add_child(ui_avg1, description="mu -> userinfo.avg1")
File "/home/rodrigo/code/django-ai/ENV/lib/python3.5/site-packages/django_dag/models.py", line 42, in add_child
return cls.save(disable_circular_check=disable_check)
TypeError: save() got an unexpected keyword argument 'disable_circular_check'
The migrations:
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-09-02 20:29
from __future__ import unicode_literals
from django.db import migrations
from bayesian_networks.bayespy_constants import (
DIST_GAUSSIAN_ARD, DIST_GAMMA)
from bayesian_networks.models import BayesianNetworkNode as BNN
def create_bn1_example(apps, schema_editor):
BayesianNetwork = apps.get_model("bayesian_networks",
"BayesianNetwork")
BayesianNetworkEdge = apps.get_model("bayesian_networks",
"BayesianNetworkEdge")
BayesianNetworkNode = apps.get_model("bayesian_networks",
"BayesianNetworkNode")
ContentType = apps.get_model("contenttypes",
"ContentType")
bn1 = BayesianNetwork(name="BN1 (Example)")
bn1.save()
# import ipdb; ipdb.set_trace()
mu = BayesianNetworkNode(
network=bn1,
name="mu",
node_type=BNN.NODE_TYPE_STOCHASTIC,
is_observable=False,
distribution=DIST_GAUSSIAN_ARD,
distribution_params="0, 1e-6",
graph_interval="-10, 20"
)
tau = BayesianNetworkNode(
network=bn1,
name="tau",
node_type=BNN.NODE_TYPE_STOCHASTIC,
is_observable=False,
distribution=DIST_GAMMA,
distribution_params="1e-6, 1e-6",
graph_interval="1e-6, 1"
)
ui_avg1 = BayesianNetworkNode(
network=bn1,
name="userinfo.avg1",
node_type=BNN.NODE_TYPE_STOCHASTIC,
is_observable=True,
distribution=DIST_GAUSSIAN_ARD,
distribution_params="mu, tau",
ref_model=ContentType.objects.get(model="userinfo",
app_label="examples"),
ref_column="avg1",
)
tau.save()
mu.save()
ui_avg1.save()
mu.add_child(ui_avg1, description="mu -> userinfo.avg1")
tau.add_child(ui_avg1, description="tau -> userinfo.avg1")
However, using
mu_to_ui_avg1 = BayesianNetworkEdge(
network=bn1,
description="mu -> userinfo.avg1",
parent=mu,
child=ui_avg1
)
mu_to_ui_avg1.save()
works, so for some reason the API shown in tests.py does not work in migrations.
In an app, a custom __unicode__()
method for my Node class can return non-ascii data. However, this breaks the __unicode__()
method of my Edge class, since it tries to insert these data into a str
template.
I would like to be able to retrieve the children in a fixed order, e.g. the order they were created.
I would also like to retrieve descendants in a fixed order.
Is there a way to guarantee this?
The package on pypi is outdated and has a typo on it that prevents the module from being loaded.
Also, it would be nice if you could include a license.
Would you mind either unchecking "Wiki" in your project settings or adding a landing page to help encourage a specific type of use?
Just a courtesy to users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.