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

bump major #452

Merged
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
24 changes: 4 additions & 20 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,7 @@ on:

jobs:
build-n-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel babel
- name: Build package
run: |
python setup.py compile_catalog sdist bdist_wheel
- name: Publish
uses: pypa/[email protected]
with:
user: __token__

password: ${{ secrets.pypi_token }}
uses: inveniosoftware/workflows/.github/workflows/pypi-publish.yml@master
secrets: inherit
with:
babel-compile-catalog: true
82 changes: 0 additions & 82 deletions .github/workflows/tests-feature.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
..
Copyright (C) 2020-2024 CERN.
Copyright (C) 2024 Graz University of Technology.

Invenio-Vocabularies is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
Expand All @@ -8,6 +9,20 @@
Changes
=======

Version 7.0.0.dev1 (released 2024-12-12)

- comp: make compatible to flask-sqlalchemy>=3.1
- setup: change to reusable workflows
- setup: bump major dependencies

Version v6.10.1 (released 2024-12-12)

- names: drop unique id on the internal id

Version v6.10.0 (released 2024-12-12)

- names: add internal id column to the name_metadata db

Version v6.9.0 (released 2024-12-09)

- schema: added identifiers in affiliations relation
Expand Down
3 changes: 2 additions & 1 deletion invenio_vocabularies/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2024 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
Expand All @@ -10,6 +11,6 @@

from .ext import InvenioVocabularies

__version__ = "6.9.0"
__version__ = "7.0.0.dev1"

__all__ = ("__version__", "InvenioVocabularies")
36 changes: 36 additions & 0 deletions invenio_vocabularies/alembic/3ba812d80559_add_internal_name_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# This file is part of Invenio.
# Copyright (C) 2024 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Add internal name ID."""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "3ba812d80559"
down_revision = "55a700f897b6"
branch_labels = ()
depends_on = None


def upgrade():
"""Upgrade database."""
op.add_column(
"name_metadata", sa.Column("internal_id", sa.String(length=255), nullable=True)
)
op.create_unique_constraint(
op.f("uq_name_metadata_internal_id"), "name_metadata", ["internal_id"]
)


def downgrade():
"""Downgrade database."""
op.drop_constraint(
op.f("uq_name_metadata_internal_id"), "name_metadata", type_="unique"
)
op.drop_column("name_metadata", "internal_id")
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Drop unique constraint from internal id."""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "af2457652217"
down_revision = "3ba812d80559"
branch_labels = ()
depends_on = None


def upgrade():
"""Upgrade database."""
op.drop_constraint("uq_name_metadata_internal_id", "name_metadata", type_="unique")
op.create_index(
op.f("ix_name_metadata_internal_id"),
"name_metadata",
["internal_id"],
unique=False,
)


def downgrade():
"""Downgrade database."""
op.drop_index(op.f("ix_name_metadata_internal_id"), table_name="name_metadata")
op.create_unique_constraint(
"uq_name_metadata_internal_id", "name_metadata", ["internal_id"]
)
24 changes: 24 additions & 0 deletions invenio_vocabularies/contrib/names/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# This file is part of Invenio.
# Copyright (C) 2024 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Names service components."""

from invenio_records_resources.services.records.components import ServiceComponent


class InternalIDComponent(ServiceComponent):
"""Service component for internal id field."""

field = "internal_id"

def create(self, identity, data=None, record=None, **kwargs):
"""Create handler."""
setattr(record, self.field, data.pop(self.field, None))

def update(self, identity, data=None, record=None, **kwargs):
"""Update handler."""
setattr(record, self.field, data.pop(self.field, None))
2 changes: 2 additions & 0 deletions invenio_vocabularies/contrib/names/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from werkzeug.local import LocalProxy

from ...services.components import PIDComponent
from .components import InternalIDComponent

names_schemes = LocalProxy(lambda: current_app.config["VOCABULARIES_NAMES_SCHEMES"])

Expand Down Expand Up @@ -67,6 +68,7 @@ class NamesSearchOptions(SearchOptions):

service_components = [
# Order of components are important!
InternalIDComponent,
DataComponent,
PIDComponent,
RelationsComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
"uniqueItems": true
}
}
}
}
4 changes: 3 additions & 1 deletion invenio_vocabularies/contrib/names/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
from invenio_records.dumpers.relations import RelationDumperExt
from invenio_records.systemfields import RelationsField
from invenio_records.systemfields import ModelField, RelationsField
from invenio_records_resources.factories.factory import RecordTypeFactory
from invenio_records_resources.records.systemfields import (
ModelPIDField,
Expand Down Expand Up @@ -47,10 +47,12 @@
# cannot set to nullable=False because it would fail at
# service level when create({}), see records-resources.
"pid": db.Column(db.String(255), unique=True),
"internal_id": db.Column(db.String(255), nullable=True, index=True),
},
schema_version="1.0.0",
schema_path="local://names/name-v1.0.0.json",
index_name="names-name-v2.0.0",
record_cls_attrs={"internal_id": ModelField("internal_id", dump=False)},
record_relations=name_relations,
record_dumper=SearchDumper(
model_fields={"pid": ("id", str)},
Expand Down
3 changes: 2 additions & 1 deletion invenio_vocabularies/contrib/names/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class NameSchema(BaseVocabularySchema, ModePIDFieldVocabularyMixin):
so it does not inherit from it.
"""

internal_id = fields.Str(allow_none=True)
name = SanitizedUnicode()
given_name = SanitizedUnicode()
family_name = SanitizedUnicode()
Expand Down Expand Up @@ -66,7 +67,7 @@ def validate_names(self, data, **kwargs):
raise ValidationError({"family_name": messages})

@validates_schema
def validate_affiliatons(self, data, **kwargs):
def validate_affiliations(self, data, **kwargs):
"""Validate names."""
affiliations = data.get("affiliations", [])
seen_names = set()
Expand Down
4 changes: 2 additions & 2 deletions invenio_vocabularies/contrib/names/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def resolve(self, identity, id_, id_type, many=False):
else:
results = self._read_many(identity, search_query, max_records=1)

# cant use the results_item because it returns dicts intead of records
# cant use the results_item because it returns dicts instead of records
total = results.hits.total["value"]
if total == 0:
# Not a PID but trated as such
# Not a PID but treated as such
raise PIDDoesNotExistError(pid_type=id_type, pid_value=id_)
if many:
for result in results:
Expand Down
20 changes: 10 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ packages = find:
python_requires = >=3.7
zip_safe = False
install_requires =
invenio-i18n>=2.0.0,<3.0.0
invenio-records-resources>=6.0.0,<7.0.0
invenio-administration>=2.0.0,<3.0.0
invenio-jobs>=1.0.0,<2.0.0
invenio-i18n>=3.0.0,<4.0.0
invenio-records-resources>=7.0.0,<8.0.0
invenio-administration>=3.0.0,<4.0.0
invenio-jobs>=3.0.0.dev1,<4.0.0
lxml>=4.5.0
# Upper pinning pycountry due to commonmeta-py
pycountry>=22.3.5,<23.0.0
Expand All @@ -49,17 +49,17 @@ sparql =
SPARQLWrapper>=2.0.0
tests =
pytest-black-ng>=0.4.0
invenio-app>=1.4.0,<2.0.0
invenio-db[postgresql,mysql]>=1.0.14,<2.0.0
invenio-app>=2.0.0,<3.0.0
invenio-db[postgresql,mysql]>=2.0.0,<3.0.0
pytest_httpserver>=1.0.10
pytest-invenio>=2.1.0,<3.0.0
pytest-invenio>=3.0.0,<4.0.0
Sphinx>=4.5
elasticsearch7 =
invenio-search[elasticsearch7]>=2.1.0,<3.0.0
invenio-search[elasticsearch7]>=3.0.0,<4.0.0
opensearch1 =
invenio-search[opensearch1]>=2.1.0,<3.0.0
invenio-search[opensearch1]>=3.0.0,<4.0.0
opensearch2 =
invenio-search[opensearch2]>=2.1.0,<3.0.0
invenio-search[opensearch2]>=3.0.0,<4.0.0
# Kept for backwards compatibility:
mysql =
postgresql =
Expand Down
3 changes: 2 additions & 1 deletion tests/contrib/names/test_names_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_simple_flow(app, service, identity, name_full_data, example_affiliation

# Create it
item = service.create(identity, name_full_data)

id_ = item.id

# add dereferenced values
Expand Down Expand Up @@ -68,7 +69,7 @@ def test_simple_flow(app, service, identity, name_full_data, example_affiliation
# Fail to retrieve it
# - db
# only the metadata is removed from the record, it is still resolvable
base_keys = {"created", "updated", "id", "links", "revision_id"}
base_keys = {"created", "updated", "id", "links", "revision_id", "internal_id"}
deleted_rec = service.read(identity, id_).to_dict()
assert set(deleted_rec.keys()) == base_keys
# - search
Expand Down
Loading