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
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
groups:
dev-deps:
dependency-type: "development"
prod-deps:
dependency-type: "production"
open-pull-requests-limit: 5
commit-message:
prefix: "deps"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions-deps:
patterns:
- "*"
open-pull-requests-limit: 5
commit-message:
prefix: "ci"

14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.9", "3.11"]
tox_env: [python] #, precommit]
services:
postgres:
image: postgres:9.6
image: postgres:11.1
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bsync_validator
Expand All @@ -28,16 +29,15 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.6.7"
python-version: ${{ matrix.python-version }}
- name: Display system info
run: python -c "import sys; print(sys.version)"
- name: Setup Python
run: |
apt-get update && apt-get install python-enchant -y
pip install tox
sudo apt-get update && sudo apt-get install python3-enchant -y
pip install --upgrade pip
pip install tox coveralls
- name: Run tox
Expand Down
62 changes: 26 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,43 @@ exclude: |

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
args: ["--maxkb=5000"]
- id: check-ast
- id: check-added-large-files
# Reduced max file size from 5000KB to 2000KB to prevent large files from being added.
args: ["--maxkb=2000"]
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- id: check-yaml
- id: check-json
- id: name-tests-test
args: ["--pytest-test-first"]
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
exclude: .*/templates
- id: debug-statements
- id: end-of-file-fixer
exclude: seed/static/seed/locales/
- id: mixed-line-ending
exclude: seed/static/seed/locales/
- id: pretty-format-json
args: ["--autofix", "--no-sort-keys"]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
args:
[
-m=VERTICAL_HANGING_INDENT,
--skip=seed/models/__init__.py,
--filter-files,
]
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake
args:
[
"--in-place",
"--recursive",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["--ignore=F401,E402,E501,E731,W503,W504"]
- repo: https://github.com/pre-commit/mirrors-prettier
files: \.(json|template)$
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
# for now ignoring html, javascript
types_or: [yaml, markdown, css, scss]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --output-format=full]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]


3 changes: 2 additions & 1 deletion bsyncviewer/lib/bedes/bedes_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from collections import Mapping, OrderedDict, defaultdict
from collections import OrderedDict, defaultdict
from collections.abc import Mapping

import xmltodict

Expand Down
24 changes: 12 additions & 12 deletions bsyncviewer/lib/schema_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def check_all_type_definitions(self):

def _read_schema(self, root_element):
full_schema = BuildingSyncSchemaRoot()
for child in root_element.getchildren():
for child in root_element:

if child.tag.endswith('element'):
if 'name' in child.attrib:
Expand Down Expand Up @@ -230,7 +230,7 @@ def _read_ref_element(self, parent_object):

ref_element.ref_type = parent_object.attrib['ref']

for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('attribute'):
ref_element.attributes.append(self._read_attribute(child))
elif child.tag.endswith('annotation'):
Expand All @@ -251,7 +251,7 @@ def _read_named_element(self, parent_object):
named_element.min_occurs = parent_object.attrib['minOccurs']
if 'maxOccurs' in parent_object.attrib:
named_element.max_occurs = parent_object.attrib['maxOccurs']
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('annotation'):
named_element.annotations.append(self._read_annotation(child))
elif child.tag.endswith('complexType'):
Expand All @@ -270,7 +270,7 @@ def _read_named_element(self, parent_object):
@staticmethod
def _read_annotation(parent_object):
annotation = AnnotationElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('documentation'):
annotation.documentation = child.text
else:
Expand All @@ -279,7 +279,7 @@ def _read_annotation(parent_object):

def _read_attribute(self, parent_object):
attribute = AttributeElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('simpleType'):
attribute.simple_types.append(self._read_simple_type(child))
elif child.tag.endswith('annotation'):
Expand All @@ -290,7 +290,7 @@ def _read_attribute(self, parent_object):

def _read_complex_type(self, parent_object):
this_complex_type = ComplexTypeElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('sequence'):
this_complex_type.sequences.append(self._read_sequence(child))
elif child.tag.endswith('simpleContent'):
Expand All @@ -312,7 +312,7 @@ def _read_complex_type(self, parent_object):

def _read_sequence(self, parent_object):
this_sequence = SequenceElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('element'):
if 'name' in child.attrib:
this_sequence.named_elements.append(self._read_named_element(child))
Expand All @@ -329,7 +329,7 @@ def _read_sequence(self, parent_object):

def _read_simple_content(self, parent_object):
this_simple_content = SimpleContentElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('extension'):
this_simple_content.extensions.append(self._read_extension(child))
else:
Expand All @@ -340,7 +340,7 @@ def _read_extension(self, parent_object):
this_extension = ExtensionElement()
if 'base' in parent_object.attrib:
this_extension.base_type = parent_object.attrib['base']
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('attribute'):
this_extension.attributes.append(self._read_attribute(child))
else:
Expand All @@ -361,7 +361,7 @@ def _read_simple_type(self, parent_object):
if parent_object.attrib and parent_object.attrib['name']:
this_simple_content.name = parent_object.attrib['name']

for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('restriction'):
this_simple_content.restrictions.append(self._read_restriction(child))
elif child.tag.endswith('annotation'):
Expand All @@ -378,7 +378,7 @@ def _read_simple_type(self, parent_object):
@staticmethod
def _read_restriction(parent_object):
this_restriction = RestrictionElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('enumeration'):
this_restriction.enumerations.append(child.attrib['value'])
elif child.tag.endswith('minInclusive'):
Expand All @@ -394,7 +394,7 @@ def _read_restriction(parent_object):

def _read_choice(self, parent_object):
this_choice = ChoiceElement()
for child in parent_object.getchildren():
for child in parent_object:
if child.tag.endswith('element'):
if 'name' in child.attrib:
this_choice.named_elements.append(self._read_named_element(child))
Expand Down
16 changes: 11 additions & 5 deletions bsyncviewer/management/commands/bedes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def parse(self, bedes_version, schema_version):
bsync_term = self.manual_mapping(attribute.name, manual_mappings)

for bt in bedes.terms:
distance = jellyfish.jaro_winkler(bsync_term.lower(), bt['Term'].lower())
# Skip if bt['Term'] is None or not a string
if not bt.get('Term') or not isinstance(bt['Term'], str):
continue
distance = jellyfish.jaro_winkler_similarity(bsync_term.lower(), bt['Term'].lower())

if distance >= 0.98:
results[attribute.id].append({
Expand All @@ -106,7 +109,7 @@ def parse(self, bedes_version, schema_version):
if not results[attribute.id]:
for be in bedes.enumerations:
# .lower() function used to neutralize upper/lower case discrepancies (there are many in enumerations/list options)
distance = jellyfish.jaro_winkler(bsync_term.lower(), be['List-Option'].lower())
distance = jellyfish.jaro_winkler_similarity(bsync_term.lower(), be['List-Option'].lower())

if distance >= 0.98:
results[attribute.id].append({
Expand Down Expand Up @@ -162,7 +165,7 @@ def parse(self, bedes_version, schema_version):
for word_group in word_groups.keys():

for bt in bedes.terms:
distance = jellyfish.jaro_winkler(word_group.lower(), bt['Term'].lower())
distance = jellyfish.jaro_winkler_similarity(word_group.lower(), bt['Term'].lower())

if distance >= 0.98:

Expand All @@ -183,7 +186,7 @@ def parse(self, bedes_version, schema_version):
# if no matches found in BEDES terms, check list options
for be in bedes.enumerations:

distance = jellyfish.jaro_winkler(word_group.lower(), be['List-Option'].lower())
distance = jellyfish.jaro_winkler_similarity(word_group.lower(), be['List-Option'].lower())

if distance >= 0.98:
for i in range(word_groups[word_group], word_groups[word_group] + number_of_words):
Expand Down Expand Up @@ -367,7 +370,10 @@ def parse(self, bedes_version, schema_version):
print(associated_attrs)

for be in bedes.enumerations:
distance = jellyfish.jaro_winkler(enumeration.name, be['List-Option'])
# Skip if be['List-Option'] is None or not a string
if not be.get('List-Option') or not isinstance(be['List-Option'], str):
continue
distance = jellyfish.jaro_winkler_similarity(enumeration.name, be['List-Option'])

if distance >= 0.95:
results[enumeration.id].append({
Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
autopep8==1.4.4
coveralls==2.2.0
coverage==5.0.1
pre-commit==3.5.0
tox==3.14.1
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ Django==2.2.28
django-bootstrap4==2.3.1
djangorestframework==3.11.2
djangorestframework-xml==1.0.1
# Version of lxml has to match what is in testsuite
lxml==4.9.1
psycopg2==2.8.6

psycopg2-binary==2.9.7

semantic-version==2.10.0
stopit==1.1.2
xmlschema==1.0.15
xmltodict==0.12.0

# string matching
jellyfish==0.7.1
jellyfish==1.2.0

# schematron runner from TestSuite repo
testsuite==0.1.3
# This also sets the version of lxml to use
testsuite==0.1.5

# production deployment
uWSGI==2.0.22
uWSGI==2.0.26
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ envlist =
passenv=
DJANGO_LOG_LEVEL
DJANGO_SETTINGS_MODULE
TRAVIS
TRAVIS_JOB_ID
TRAVIS_BRANCH
commands = coverage run manage.py test
deps = -r{toxinidir}/requirements-test.txt

Expand Down