Skip to content

Commit

Permalink
Feature/sckan 226 (#202)
Browse files Browse the repository at this point in the history
* SCKAN-226 feat: Update ingestion script

* SCKAN-226 chore: Refactor add_destination to match with add_vias

* SCKAN-226 feat: Enforce reference_uri uniqueness

* SCKAN-226 feat: Update ingestion logic

* SCKAN-226 feat: WIP - Update neurondm script

* SCKAN-226 feat: WIP - Undo validation neurondm script

* SCKAN-226 feat: Use predicates in partial order processing

* SCKAN-226 feat: Merge vias that differ only on from_entities

* SCKAN-226 feat: Merge destinations

* SCKAN-226 feat: Merge destinations by from_entities

* SCKAN-226 feat: Merge origins

* SCKAN-226 feat: Update ingestion script

* SCKAN-226 feat: Test both region and layer on entity identification

* SCKAN-226 feat: Update ingestion script

* SCKAN-226 feat: Update default state on ingestion creation

* SCKAN-226 feat: Add forward connection ingestion

* SCKAN-226 feat: WIP - Update validation and add logging service

* SCKAN-226 feat: Make ingestion atomic; Update logging service

* SCKAN-226 fix: Update forward connection check

* SCKAN-226 refactor: Use update_or_create instead of custom method

* SCKAN-226 feat: Add new transition draft to exported for ingestion

* SCKAN-226 feat: Remove unnecessary transition

* SCKAN-248 fix: Update journey tests

* SCKAN-248 feat: Add tests to neurondm processing

* SCKAN-248 feat: WIP - Ignore partial order mismatches

* Revert "SCKAN-226 feat: Remove unnecessary transition"

This reverts commit d29ac5a.

* SCKAN-226 feat: Use .update and .create instead of .update_or_create

* SCKAN-226 refactor: Use .get_or_create instead of filter

* SCKAN-226 refactor: Remove __exact from filter

* SCKAN-226 refactor: Add has_changes check

* SCKAN-226 feat: Ingest inconsistent populations but flag them with warnings

* SCKAN-248 feat: Add invalid state; Update ingestion accordingly

* SCKAN-248 feat: Optimize upstream algorithm

* SCKAN-248 chore: Remove TODO annotation

* SCKAN-248 feat: Add note on step 3 even if state was invalid

* SCKAN-248 feat: Allow transition to invalid from any state

* SCKAN-248 fix: Update process connection algorithm and jump test

* SCKAN-248 feat: Update process connection algorithm and multiple axioms test

* SCKAN-248 feat: Add partial order vs axioms validation

* SCKAN-248 fix: Update has_changes logic

* SCKAN-248 feat: Update notes

* SCKAN-248 feat: Remove deprecated method
  • Loading branch information
afonsobspinto authored Feb 7, 2024
1 parent 3f615cc commit d84fa3a
Show file tree
Hide file tree
Showing 15 changed files with 1,198 additions and 360 deletions.
1 change: 1 addition & 0 deletions backend/composer/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CSState(models.TextChoices):
CONNECTION_MISSING = "connection_missing"
NPO_APPROVED = "npo_approved"
EXPORTED = "exported"
INVALID = "invalid"


class NoteType(models.TextChoices):
Expand Down
10 changes: 9 additions & 1 deletion backend/composer/management/commands/ingest_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
class Command(BaseCommand):
help = "Ingests Statements from neurondm pyp package"

def add_arguments(self, parser):
parser.add_argument(
'--update_upstream',
action='store_true',
help='Set this flag to update upstream statements.',
)

def handle(self, *args, **options):
ingest_statements()
update_upstream = options['update_upstream']
ingest_statements(update_upstream)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.4 on 2024-01-05 15:46

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("composer", "0032_alter_connectivitystatement_projection"),
]

operations = [
migrations.AlterField(
model_name="connectivitystatement",
name="reference_uri",
field=models.URLField(blank=True, null=True, unique=True),
),
]
27 changes: 24 additions & 3 deletions backend/composer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class ConnectivityStatement(models.Model):
)
apinatomy_model = models.CharField(max_length=200, null=True, blank=True)
additional_information = models.TextField(null=True, blank=True)
reference_uri = models.URLField(null=True, blank=True)
reference_uri = models.URLField(null=True, blank=True, unique=True)
functional_circuit_role = models.ForeignKey(
FunctionalCircuitRole,
on_delete=models.DO_NOTHING,
Expand Down Expand Up @@ -443,6 +443,7 @@ def __str__(self):
CSState.REJECTED,
CSState.NPO_APPROVED,
CSState.EXPORTED,
CSState.INVALID
],
permission=lambda instance, user: ConnectivityStatementService.has_permission_to_transition_to_compose_now(
instance, user
Expand Down Expand Up @@ -500,6 +501,26 @@ def npo_approved(self, *args, **kwargs):
def exported(self, *args, **kwargs):
...

@transition(
field=state,
source=[
CSState.DRAFT,
CSState.COMPOSE_NOW,
CSState.CURATED,
CSState.EXCLUDED,
CSState.REJECTED,
CSState.TO_BE_REVIEWED,
CSState.CONNECTION_MISSING,
CSState.NPO_APPROVED,
CSState.EXPORTED,
],
target=CSState.INVALID,
permission=lambda instance, user: ConnectivityStatementService.has_permission_to_transition_to_invalid(
instance, user
), )
def invalid(self, *args, **kwargs):
...

@property
def export_id(self):
return f"CPR:{self.id:06d}"
Expand Down Expand Up @@ -590,7 +611,7 @@ class Destination(AbstractConnectionLayer):
choices=DestinationType.choices,
default=DestinationType.UNKNOWN
)

objects = DestinationManager()

class Meta:
Expand All @@ -604,7 +625,7 @@ class Meta:

class Via(AbstractConnectionLayer):
anatomical_entities = models.ManyToManyField(AnatomicalEntity, blank=True, related_name='via_connection_layers')

objects = ViaManager()

type = models.CharField(
Expand Down
Empty file.
Loading

0 comments on commit d84fa3a

Please sign in to comment.