Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Person and Reference models #5

Merged
merged 12 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ docs/conf.py
_docs_tmp*
docs/test-ourprojects/
test-ourprojects/
test.ipynb
run-tests
4 changes: 3 additions & 1 deletion ourprojects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
.. autosummary::
:toctree: .

Person
Project
Reference
"""

__version__ = "0.0.1" # denote a pre-release for 0.1.0 with 0.1rc1
Expand All @@ -32,4 +34,4 @@ def __getattr__(name):
import lamindb

del __getattr__ # delete so that imports work out
from .models import Project
from .models import Person, Project, Reference
Zethson marked this conversation as resolved.
Show resolved Hide resolved
311 changes: 308 additions & 3 deletions ourprojects/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 5.2 on 2024-11-21 10:57
# Generated by Django 5.1.3 on 2024-11-21 16:00

import django.core.validators
import django.db.models.deletion
import lnschema_core.fields
import lnschema_core.ids
Expand Down Expand Up @@ -42,7 +43,6 @@ class Migration(migrations.Migration):
"artifact",
lnschema_core.fields.ForeignKey(
blank=True,
default=None,
on_delete=django.db.models.deletion.CASCADE,
related_name="links_project",
to="lnschema_core.artifact",
Expand Down Expand Up @@ -83,6 +83,149 @@ class Migration(migrations.Migration):
],
bases=(lnschema_core.models.LinkORM, models.Model),
),
migrations.CreateModel(
name="ArtifactReference",
fields=[
(
"created_at",
lnschema_core.fields.DateTimeField(
auto_now_add=True, db_index=True
),
),
("id", models.BigAutoField(primary_key=True, serialize=False)),
(
"label_ref_is_name",
lnschema_core.fields.BooleanField(
blank=True, default=None, null=True
),
),
(
"feature_ref_is_name",
lnschema_core.fields.BooleanField(
blank=True, default=None, null=True
),
),
(
"artifact",
lnschema_core.fields.ForeignKey(
blank=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="links_reference",
to="lnschema_core.artifact",
),
),
(
"created_by",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.users.current_user_id,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.user",
),
),
(
"feature",
lnschema_core.fields.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="links_artifactreference",
to="lnschema_core.feature",
),
),
(
"run",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.models.current_run,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.run",
),
),
],
bases=(lnschema_core.models.LinkORM, models.Model),
),
migrations.CreateModel(
name="Person",
fields=[
(
"created_at",
lnschema_core.fields.DateTimeField(
auto_now_add=True, db_index=True
),
),
(
"updated_at",
lnschema_core.fields.DateTimeField(auto_now=True, db_index=True),
),
("id", models.AutoField(primary_key=True, serialize=False)),
(
"uid",
lnschema_core.fields.CharField(
blank=True,
db_index=True,
default=lnschema_core.ids.base62_8,
max_length=8,
unique=True,
),
),
(
"name",
lnschema_core.fields.CharField(
blank=True, db_index=True, default=None, max_length=255
),
),
(
"email",
lnschema_core.fields.EmailField(
blank=True, default=None, max_length=254, null=True
),
),
(
"internal",
lnschema_core.fields.BooleanField(
blank=True, db_index=True, default=False
),
),
(
"_previous_runs",
models.ManyToManyField(related_name="+", to="lnschema_core.run"),
),
(
"created_by",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.users.current_user_id,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.user",
),
),
(
"run",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.models.current_run,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.run",
),
),
],
options={
"abstract": False,
},
bases=(
lnschema_core.models.CanCurate,
models.Model,
lnschema_core.models.ValidateFields,
),
),
migrations.CreateModel(
name="Project",
fields=[
Expand All @@ -101,6 +244,7 @@ class Migration(migrations.Migration):
"uid",
lnschema_core.fields.CharField(
blank=True,
db_index=True,
default=lnschema_core.ids.base62_12,
max_length=12,
unique=True,
Expand Down Expand Up @@ -151,6 +295,12 @@ class Migration(migrations.Migration):
to="lnschema_core.user",
),
),
(
"people",
models.ManyToManyField(
related_name="project_people", to="ourprojects.person"
),
),
(
"run",
lnschema_core.fields.ForeignKey(
Expand All @@ -177,14 +327,169 @@ class Migration(migrations.Migration):
name="project",
field=lnschema_core.fields.ForeignKey(
blank=True,
default=None,
on_delete=django.db.models.deletion.PROTECT,
related_name="links_artifact",
to="ourprojects.project",
),
),
migrations.CreateModel(
name="Reference",
fields=[
(
"created_at",
lnschema_core.fields.DateTimeField(
auto_now_add=True, db_index=True
),
),
(
"updated_at",
lnschema_core.fields.DateTimeField(auto_now=True, db_index=True),
),
("id", models.AutoField(primary_key=True, serialize=False)),
(
"uid",
lnschema_core.fields.CharField(
blank=True,
db_index=True,
default=lnschema_core.ids.base62_12,
max_length=12,
unique=True,
),
),
(
"name",
lnschema_core.fields.CharField(
blank=True, db_index=True, default=None, max_length=255
),
),
(
"abbr",
lnschema_core.fields.CharField(
blank=True,
db_index=True,
default=None,
max_length=32,
null=True,
unique=True,
),
),
("url", lnschema_core.fields.URLField(blank=True, null=True)),
(
"pubmed_id",
lnschema_core.fields.BigIntegerField(
blank=True, db_index=True, null=True
),
),
(
"doi",
lnschema_core.fields.CharField(
blank=True,
db_index=True,
default=None,
max_length=255,
null=True,
validators=[
django.core.validators.RegexValidator(
message="Must be a DOI (e.g., 10.1000/xyz123 or https://doi.org/10.1000/xyz123)",
regex="^(?:https?://(?:dx\\.)?doi\\.org/|doi:|DOI:)?10\\.\\d+/.*$",
)
],
),
),
(
"preprint",
lnschema_core.fields.BooleanField(
blank=True, db_index=True, default=False
),
),
(
"journal",
lnschema_core.fields.TextField(blank=True, default=None, null=True),
),
(
"description",
lnschema_core.fields.TextField(blank=True, default=None, null=True),
),
(
"text",
lnschema_core.fields.TextField(blank=True, default=None, null=True),
),
(
"published_at",
lnschema_core.fields.DateField(blank=True, default=None, null=True),
),
(
"_previous_runs",
models.ManyToManyField(related_name="+", to="lnschema_core.run"),
),
(
"artifacts",
models.ManyToManyField(
related_name="references",
through="ourprojects.ArtifactReference",
to="lnschema_core.artifact",
),
),
(
"authors",
models.ManyToManyField(
related_name="references", to="ourprojects.person"
),
),
(
"created_by",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.users.current_user_id,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.user",
),
),
(
"run",
lnschema_core.fields.ForeignKey(
blank=True,
default=lnschema_core.models.current_run,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.run",
),
),
],
options={
"abstract": False,
},
bases=(
lnschema_core.models.CanCurate,
models.Model,
lnschema_core.models.ValidateFields,
),
),
migrations.AddField(
model_name="project",
name="references",
field=models.ManyToManyField(
related_name="project_references", to="ourprojects.reference"
),
),
migrations.AddField(
model_name="artifactreference",
name="reference",
field=lnschema_core.fields.ForeignKey(
blank=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="links_artifact",
to="ourprojects.reference",
),
),
migrations.AlterUniqueTogether(
name="artifactproject",
unique_together={("artifact", "project", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactreference",
unique_together={("artifact", "reference", "feature")},
),
]
Loading
Loading