Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,63 @@ Redistribution and use in source and binary forms, with or without modification,

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Some of the Sumatra code is taken from/based on the django-tagging package:

Django Tagging
--------------

Copyright (c) 2007-2015, Jonathan Buchanan, Julien Fache

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Initially based on code from James Bennett's Cab:

Cab
---

Copyright (c) 2007, James Bennett
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Requirements
============

Sumatra requires Python version 3.9 or later The web interface requires
Django (>= 4.2) and the django-tagging package.
Django (>= 4.2).
Sumatra requires that you keep your own code in a version control
system (currently Subversion, Mercurial, Git and Bazaar are supported). If you
are already using Bazaar there is nothing else to install. If you
Expand Down
8 changes: 8 additions & 0 deletions doc/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ Licence
=======

Sumatra is freely available under the BSD 2-clause license.


django-tagging
==============

Some of the code in Sumatra's `django_store` module is taken from or based on
the django-tagging package, by Jonathan Buchanan and Julien Fache,
which in turn was based on the Cab package by James Bennett.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ hg = ["mercurial", "hgapi"]

web = [
"docutils",
"Django<6",
"django-tagging@git+https://github.com/jazzband/django-tagging"
"Django<6"
]

remote = ["httplib2"]
Expand Down
11 changes: 3 additions & 8 deletions sumatra/recordstore/django_store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
from urllib.request import urlparse
from io import StringIO

# Check that django-tagging is available. It would be better to try importing
# it, but that seems to mess with Django's internals.
importlib.util.find_spec("tagging")


def db_id(db):
"""Return a unique identifier for a database, for comparison purposes."""
Expand All @@ -49,8 +45,7 @@ def __init__(self):
'DEBUG': True,
'DATABASES': {},
'INSTALLED_APPS': ['sumatra.recordstore.django_store',
'django.contrib.contenttypes', # needed for tagging
'tagging'],
'django.contrib.contenttypes'],
'MIDDLEWARE_CLASSES': [],
'READ_ONLY': 0,
'SERVERSIDE': 0,
Expand Down Expand Up @@ -329,8 +324,8 @@ def clear(self):
cmds = ["BEGIN;"] + ['DROP TABLE "django_store_{0}";'.format(x)
for x in ("record", "record_input_data", "record_dependencies",
"record_platforms", "platforminformation", "datakey", "datastore", "launchmode",
"taggeditem", "tag",
"parameterset", "repository", "dependency", "executable", "project")] + ["COMMIT;"]
# todo: also drop tagging_taggeditem, tagging_tag
from django.db import connection
cur = connection.cursor()
for cmd in cmds:
Expand All @@ -344,7 +339,7 @@ def _dump(self, indent=2):
import sys
data = StringIO()
sys.stdout = data
management.call_command('dumpdata', 'django_store', 'tagging', indent=indent)
management.call_command('dumpdata', 'django_store', indent=indent)
sys.stdout = sys.__stdout__
data.seek(0)
return data.read()
Expand Down
5 changes: 3 additions & 2 deletions sumatra/recordstore/django_store/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generated by Django 5.2 on 2025-04-16 08:53

import django.db.models.deletion
import tagging.fields
from django.db import migrations, models

from ..models import TagField


class Migration(migrations.Migration):

Expand Down Expand Up @@ -139,7 +140,7 @@ class Migration(migrations.Migration):
('version', models.CharField(max_length=50)),
('outcome', models.TextField(blank=True)),
('timestamp', models.DateTimeField()),
('tags', tagging.fields.TagField(blank=True, max_length=255)),
('tags', TagField(blank=True, max_length=255)),
('diff', models.TextField(blank=True)),
('user', models.CharField(max_length=100)),
('script_arguments', models.TextField(blank=True)),
Expand Down
41 changes: 41 additions & 0 deletions sumatra/recordstore/django_store/migrations/0002_tag_taggeditem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 5.2 on 2025-04-18 14:15

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('django_store', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(db_index=True, max_length=50, unique=True, verbose_name='name')),
],
options={
'verbose_name': 'tag',
'verbose_name_plural': 'tags',
'ordering': ('name',),
},
),
migrations.CreateModel(
name='TaggedItem',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.PositiveIntegerField(db_index=True, verbose_name='object id')),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='content type')),
('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='django_store.tag', verbose_name='tag')),
],
options={
'verbose_name': 'tagged item',
'verbose_name_plural': 'tagged items',
'unique_together': {('tag', 'content_type', 'object_id')},
},
),
]
17 changes: 8 additions & 9 deletions sumatra/recordstore/django_store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
:license: BSD 2-clause, see LICENSE for details.
"""

from datetime import datetime
import json

from packaging.version import parse as parse_version
from django.db import models
import django

from sumatra import programs, launch, datastore, records, versioncontrol, parameters, dependency_finder
from sumatra.datastore import get_data_store
from datetime import datetime
import django
from packaging.version import parse as parse_version
from sumatra.core import get_registered_components
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import tagging.fields
from tagging.models import Tag

from .tagging import TagField, Tag, TaggedItem, TagManager


class SumatraObjectsManager(models.Manager):
Expand Down Expand Up @@ -257,7 +256,7 @@ class Record(BaseModel):
input_datastore = models.ForeignKey(Datastore, related_name="input_to_records", on_delete=models.PROTECT)
outcome = models.TextField(blank=True)
timestamp = models.DateTimeField()
tags = tagging.fields.TagField()
tags = TagField()
dependencies = models.ManyToManyField(Dependency)
platforms = models.ManyToManyField(PlatformInformation)
diff = models.TextField(blank=True)
Expand Down
Loading