Skip to content

Commit

Permalink
Merge pull request #199 from archesproject/main
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongundel authored Jan 31, 2025
2 parents e1de531 + 9668167 commit b18119c
Show file tree
Hide file tree
Showing 69 changed files with 65,285 additions and 68,197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.log
node_modules
coverage/
arches_lingo/list_item_images/*
arches_lingo/logs
arches_lingo/export_deliverables
arches_lingo/cantaloupe/*
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add login interface [#13](https://github.com/archesproject/arches-lingo/issues/13)
- Add front-end router [#11](https://github.com/archesproject/arches-lingo/issues/11)
- Add dark mode toggle [#91](https://github.com/archesproject/arches-lingo/issues/91)
- Add concept and scheme serializers [#103](https://github.com/archesproject/arches-lingo/issues/103)
- Add backend for search [#67](https://github.com/archesproject/arches-lingo/issues/67)
- Add concept and scheme pages [#15](https://github.com/archesproject/arches-lingo/issues/15)
- Add concept hierarchy component [#18](https://github.com/archesproject/arches-lingo/issues/18)
- Add scheme creation [#157](https://github.com/archesproject/arches-lingo/issues/157)

### Fixed
- Merge language finder implementations [#92](https://github.com/archesproject/arches-lingo/issues/92)

### Deprecated

Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@
source ENV/bin/activate
```
5. Navigate to the arches-rdm package, and install it into the virtual environment:
5. Navigate to the `arches-lingo` directory, and install the project (with development dependencies):
```
cd arches
pip install -e .
cd arches-lingo
pip install -e '.[dev]'
```
6. Navigate to the arches_lingo, and install the python requirements:
6. Also install core arches for local development:
```
cd ../arches-lingo
pip install -r arches_lingo/install/requirements.txt
pip install -e ../arches
```
7. Run the Django server:
Expand All @@ -54,9 +53,8 @@
source ENV/bin/activate
```
10. Navigate to your project then install the frontend dependencies.
10. (From the `arches-lingo` top-level directory) install the frontend dependencies:
```
cd arches-lingo/
npm install
```
Expand All @@ -68,21 +66,27 @@
12. If you ran `npm start` in the previous step, you will need to open a new terminal window and activate the virtual environment in the new terminal window. If you ran `npm run build_development` then you can skip this step.
13. Navigate to the arches_lingo top-level directory, and install the ontologies, branches, and resource models from the arches-rdm package.
13. Install the ontologies, branches, and resource models from the package.
```
python manage.py setup_db
python manage.py packages -o load_package -s arches_lingo/pkg --yes -db
python manage.py packages -o load_package -a arches_lingo --yes -db
```
14. Load the test data:
```
python manage.py packages -o import_business_data -s tests/fixtures/data/aat_entries_scheme_examples.json -ow overwrite
python manage.py packages -o import_business_data -s tests/fixtures/data/aat_entries_concept_examples.json -ow overwrite
```
14. In the terminal window that is running the Django server, halt the server and restart it.
15. In the terminal window that is running the Django server, halt the server and restart it.
```
(ctrl+c to halt the server)
python manage.py runserver
```
## Committing changes
NOTE: Changes are commited to the arches-rdm repository.
NOTE: Changes are committed to the arches-lingo repository.
1. Navigate to the repository
```
Expand All @@ -91,7 +95,7 @@ NOTE: Changes are commited to the arches-rdm repository.
2. Cut a new git branch
```
git checkout origin/master -b my-descriptive-branch-name
git checkout origin/main -b my-descriptive-branch-name
```
3. If updating models or branches
Expand Down
Empty file.
42 changes: 33 additions & 9 deletions arches_lingo/etl_modules/migrate_to_lingo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.db import connection
from django.db.models import OuterRef, Subquery
from django.db.models.functions import Coalesce
from django.utils.translation import gettext as _
from arches.app.datatypes.datatypes import DataTypeFactory
from arches.app.etl_modules.save import save_to_tiles
from arches.app.etl_modules.decorators import load_data_async
Expand Down Expand Up @@ -292,7 +293,7 @@ def build_concept_hierarchy(self, cursor, scheme_conceptid):
cursor.execute(
"""
with recursive collection_hierarchy as (
select conceptidfrom as root_list,
select conceptidfrom as root_scheme,
conceptidto as child,
ARRAY[conceptidfrom] AS path,
0 as depth
Expand All @@ -301,7 +302,7 @@ def build_concept_hierarchy(self, cursor, scheme_conceptid):
select 1 from relations r2 where r2.conceptidto = relations.conceptidfrom
) and relationtype != 'member'
union all
select ch.root_list,
select ch.root_scheme,
r.conceptidto,
ch.path || r.conceptidfrom,
ch.depth + 1
Expand All @@ -311,7 +312,7 @@ def build_concept_hierarchy(self, cursor, scheme_conceptid):
)
select *
from collection_hierarchy
where root_list = %s;
where root_scheme = %s;
""",
(scheme_conceptid,),
)
Expand All @@ -320,7 +321,7 @@ def build_concept_hierarchy(self, cursor, scheme_conceptid):
concepts_to_migrate = []
for result in results:
concept_dict = {
"root_list": result[0],
"root_scheme": result[0],
"concept": result[1],
"path": result[2],
"depth": result[3],
Expand Down Expand Up @@ -353,7 +354,7 @@ def init_relationships(
'valid', true,
'value', json_build_array(json_build_object('resourceId', conceptidfrom, 'ontologyProperty', '', 'resourceXresourceId', '', 'inverseOntologyProperty', '')),
'source', conceptidfrom,
'datatype', 'resource-instance-list'
'datatype', 'resource-instance'
)
) as value,
conceptidto as resourceinstanceid, -- map target concept's new resourceinstanceid to its existing conceptid
Expand Down Expand Up @@ -442,24 +443,47 @@ def init_relationships(
part_of_scheme_nodegroup = NodeGroup.objects.get(
nodegroupid=CONCEPTS_PART_OF_SCHEME_NODEGROUP_ID
)
concepts_with_scheme = {}
for concept in concept_hierarchy:
root_list = str(concept["root_list"])
root_scheme = str(concept["root_scheme"])
resourceinstanceid = concept["concept"]

concept_has_part_of_scheme = resourceinstanceid in concepts_with_scheme
existing_scheme = concepts_with_scheme.get(resourceinstanceid)
if not concept_has_part_of_scheme:
concepts_with_scheme[resourceinstanceid] = root_scheme
elif concept_has_part_of_scheme and existing_scheme == root_scheme:
continue
elif concept_has_part_of_scheme and existing_scheme != root_scheme:
return {
"status": 400,
"success": False,
"title": "Concepts may only participate in one scheme",
"message": _(
"Concept {conceptid} cannot have multiple schemes: {current_scheme} and {existing_scheme}"
).format(
{
"conceptid": resourceinstanceid,
"current_scheme": root_scheme,
"existing_scheme": concepts_with_scheme[resourceinstanceid],
}
),
}

value_obj = {
str(CONCEPTS_PART_OF_SCHEME_NODEGROUP_ID): {
"notes": "",
"valid": True,
"value": [
{
"resourceId": root_list,
"resourceId": root_scheme,
"ontologyProperty": "",
"resourceXresourceId": "",
"inverseOntologyProperty": "",
}
],
"source": root_list,
"datatype": "resource-instance-list",
"source": root_scheme,
"datatype": "resource-instance",
}
}

Expand Down
3 changes: 1 addition & 2 deletions arches_lingo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class Migration(migrations.Migration):
CREATE VIEW arches_lingo__vw_label_values AS (
SELECT
t.resourceinstanceid AS conceptid,
ROW_TO_JSON(JSONB_EACH(t.tiledata -> '{CONCEPT_NAME_CONTENT_NODE}'))
-> 'value' ->> 'value' AS value
t.tiledata ->> '{CONCEPT_NAME_CONTENT_NODE}' AS value
FROM
tiles t
ORDER BY
Expand Down
7 changes: 5 additions & 2 deletions arches_lingo/migrations/0002_load_lingo_lists.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import io
import os
from django.db import migrations

from django.core import management
from django.db import migrations

from arches_lingo.settings import APP_ROOT
from arches_references.models import List, ListItem, ListItemValue


class Migration(migrations.Migration):
Expand All @@ -22,6 +24,7 @@ def load_lists(apps, schema_editor):
"controlled_lists",
"lingo_lists.json",
),
stdout=io.StringIO(),
)

operations = [
Expand Down
Loading

0 comments on commit b18119c

Please sign in to comment.