diff --git a/lib/rucio/core/config.py b/lib/rucio/core/config.py index 61bd4f90ab..d556596583 100644 --- a/lib/rucio/core/config.py +++ b/lib/rucio/core/config.py @@ -19,7 +19,7 @@ from rucio.common.cache import CacheKey, MemcacheRegion from rucio.common.exception import ConfigNotFound -from rucio.db.sqla import models +from rucio.db.sqla.models import Config from rucio.db.sqla.session import read_session, transactional_session T = TypeVar('T') @@ -56,7 +56,7 @@ def sections( all_sections = read_from_cache(SECTIONS_CACHE_KEY, expiration_time) if isinstance(all_sections, NoValue): stmt = select( - models.Config.section + Config.section ).distinct( ) all_sections = list(session.execute(stmt).scalars().all()) @@ -99,9 +99,9 @@ def has_section( has_section = read_from_cache(has_section_key, expiration_time) if isinstance(has_section, NoValue): stmt = select( - models.Config + Config ).where( - models.Config.section == section + Config.section == section ) has_section = session.execute(stmt).first() is not None write_to_cache(has_section_key, has_section) @@ -131,9 +131,9 @@ def options( options = read_from_cache(options_key, expiration_time) if isinstance(options, NoValue): stmt = select( - models.Config.opt + Config.opt ).where( - models.Config.section == section + Config.section == section ).distinct() options = list(session.execute(stmt).scalars().all()) write_to_cache(options_key, options) @@ -165,10 +165,10 @@ def has_option( has_option = read_from_cache(has_option_key, expiration_time) if isinstance(has_option, NoValue): stmt = select( - models.Config + Config ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ) has_option = session.execute(stmt).first() is not None write_to_cache(has_option_key, has_option) @@ -207,10 +207,10 @@ def get( value = read_from_cache(value_key, expiration_time) if isinstance(value, NoValue): stmt = select( - models.Config.value + Config.value ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ) tmp = session.execute(stmt).first() if tmp is not None: @@ -251,10 +251,10 @@ def items( items = read_from_cache(items_key, expiration_time) if isinstance(items, NoValue): stmt = select( - models.Config.opt, - models.Config.value + Config.opt, + Config.value ).where( - models.Config.section == section + Config.section == section ) items = session.execute(stmt).all() write_to_cache(items_key, items) @@ -281,7 +281,7 @@ def set( if not has_option(section=section, option=option, use_cache=False, session=session): section_existed = has_section(section=section) - new_option = models.Config(section=section, opt=option, value=value) + new_option = Config(section=section, opt=option, value=value) new_option.save(session=session) delete_from_cache(key=CacheKey.value(section, option)) @@ -292,24 +292,24 @@ def set( delete_from_cache(key=CacheKey.has_section(section)) else: stmt = select( - models.Config.value + Config.value ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ) old_value = session.execute(stmt).scalar_one_or_none() if old_value != str(value): - old_option = models.ConfigHistory(section=section, + old_option = ConfigHistory(section=section, opt=option, value=old_value) old_option.save(session=session) stmt = update( - models.Config + Config ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ).values({ - models.Config.value: str(value) + Config.value: str(value) }) session.execute(stmt) delete_from_cache(key=CacheKey.value(section, option)) @@ -330,12 +330,12 @@ def remove_section(section: str, *, session: "Session") -> bool: return False else: stmt = select( - models.Config.value + Config.value ).where( - models.Config.section == section + Config.section == section ) for old in session.execute(stmt).all(): - old_option = models.ConfigHistory(section=old[0], + old_option = ConfigHistory(section=old[0], opt=old[1], value=old[2]) old_option.save(session=session) @@ -343,9 +343,9 @@ def remove_section(section: str, *, session: "Session") -> bool: delete_from_cache(key=CacheKey.value(old[0], old[1])) stmt = delete( - models.Config + Config ).where( - models.Config.section == section + Config.section == section ) session.execute(stmt) delete_from_cache(key=SECTIONS_CACHE_KEY) @@ -368,31 +368,31 @@ def remove_option(section: str, option: str, *, session: "Session") -> bool: return False else: stmt = select( - models.Config.value + Config.value ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ) result = session.execute(stmt).scalar_one_or_none() - old_option = models.ConfigHistory(section=section, + old_option = ConfigHistory(section=section, opt=option, value=result) old_option.save(session=session) stmt = delete( - models.Config + Config ).where( - and_(models.Config.section == section, - models.Config.opt == option) + and_(Config.section == section, + Config.opt == option) ) session.execute(stmt) stmt = select( func.count() ).select_from( - models.Config + Config ).where( - models.Config.section == section + Config.section == section ) if not session.execute(stmt).scalar_one_or_none(): # we deleted the last config entry in the section. Invalidate the section cache diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py index bf6b4023a9..6d321e3737 100644 --- a/lib/rucio/db/sqla/models.py +++ b/lib/rucio/db/sqla/models.py @@ -25,8 +25,10 @@ from sqlalchemy.sql import Delete from sqlalchemy.types import LargeBinary +# schema must be imported as a module to avoid circular imports with policy packages, +# and it must be renamed to avoid conflicts with the policy package schema modules +from rucio.common import schema as common_schema from rucio.common import utils -from rucio.common.schema import get_schema_value from rucio.common.types import InternalAccount, InternalScope # noqa: TCH001 (types are needed by SQLAlchemy) from rucio.db.sqla.constants import ( AccountStatus, @@ -317,7 +319,7 @@ def delete(self, flush: bool = True, session: Optional["Session"] = None) -> Non class Account(BASE, ModelBase): """Represents an account""" __tablename__ = 'accounts' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) account_type: Mapped[AccountType] = mapped_column(Enum(AccountType, name='ACCOUNTS_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -336,7 +338,7 @@ class Account(BASE, ModelBase): class AccountAttrAssociation(BASE, ModelBase): """Represents an account""" __tablename__ = 'account_attr_map' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) key: Mapped[str] = mapped_column(String(255)) value: Mapped[Optional[Union[bool, str]]] = mapped_column(BooleanString(255)) _table_args = (PrimaryKeyConstraint('account', 'key', name='ACCOUNT_ATTR_MAP_PK'), @@ -367,7 +369,7 @@ class IdentityAccountAssociation(BASE, ModelBase): identity_type: Mapped[IdentityType] = mapped_column(Enum(IdentityType, name='ACCOUNT_MAP_ID_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) is_default: Mapped[bool] = mapped_column(Boolean(name='ACCOUNT_MAP_DEFAULT_CHK', create_constraint=True), default=False) _table_args = (PrimaryKeyConstraint('identity', 'identity_type', 'account', name='ACCOUNT_MAP_PK'), @@ -380,8 +382,8 @@ class IdentityAccountAssociation(BASE, ModelBase): class Scope(BASE, ModelBase): """Represents a scope""" __tablename__ = 'scopes' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) is_default: Mapped[bool] = mapped_column(Boolean(name='SCOPES_DEFAULT_CHK', create_constraint=True), default=False) status: Mapped[ScopeStatus] = mapped_column(Enum(ScopeStatus, name='SCOPE_STATUS_CHK', @@ -400,9 +402,9 @@ class Scope(BASE, ModelBase): class DataIdentifier(BASE, ModelBase): """Represents a dataset""" __tablename__ = 'dids' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='DIDS_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -469,8 +471,8 @@ class DataIdentifier(BASE, ModelBase): class VirtualPlacements(BASE, ModelBase): """Represents virtual placements""" __tablename__ = 'virtual_placements' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) placements = mapped_column(JSON()) _table_args = (PrimaryKeyConstraint('scope', 'name', name='VP_PK'), ForeignKeyConstraint(['scope', 'name'], ['dids.scope', 'dids.name'], name='VP_FK') @@ -479,8 +481,8 @@ class VirtualPlacements(BASE, ModelBase): class DidMeta(BASE, ModelBase): __tablename__ = 'did_meta' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) meta: Mapped[Optional[Union[str, dict[str, Any]]]] = mapped_column(JSON()) did_type: Mapped[Optional[DIDType]] = mapped_column(Enum(DIDType, name='DID_META_DID_TYPE_CHK', create_constraint=True, @@ -492,8 +494,8 @@ class DidMeta(BASE, ModelBase): class DeletedDidMeta(BASE, ModelBase): __tablename__ = 'deleted_did_meta' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[Optional[DIDType]] = mapped_column(Enum(DIDType, name='DEL_DID_META_DID_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -506,9 +508,9 @@ class DeletedDidMeta(BASE, ModelBase): class DeletedDataIdentifier(BASE, ModelBase): """Represents a dataset""" __tablename__ = 'deleted_dids' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='DEL_DIDS_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -564,8 +566,8 @@ class UpdatedDID(BASE, ModelBase): """Represents the recently updated dids""" __tablename__ = 'updated_dids' id: Mapped[uuid.UUID] = mapped_column(GUID(), default=utils.generate_uuid) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rule_evaluation_action: Mapped[DIDReEvaluation] = mapped_column(Enum(DIDReEvaluation, name='UPDATED_DIDS_RULE_EVAL_ACT_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -578,15 +580,15 @@ class UpdatedDID(BASE, ModelBase): class BadReplica(BASE, ModelBase): """Represents the suspicious or bad replicas""" __tablename__ = 'bad_replicas' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) reason: Mapped[Optional[str]] = mapped_column(String(255)) state: Mapped[BadFilesStatus] = mapped_column(Enum(BadFilesStatus, name='BAD_REPLICAS_STATE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=BadFilesStatus.SUSPICIOUS) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) bytes: Mapped[Optional[int]] = mapped_column(BigInteger) expires_at: Mapped[Optional[datetime]] = mapped_column(DateTime) _table_args = (PrimaryKeyConstraint('scope', 'name', 'rse_id', 'state', 'created_at', name='BAD_REPLICAS_STATE_PK'), @@ -608,7 +610,7 @@ class BadPFN(BASE, ModelBase): values_callable=lambda obj: [e.value for e in obj]), default=BadPFNStatus.SUSPICIOUS) reason: Mapped[Optional[str]] = mapped_column(String(255)) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) expires_at: Mapped[Optional[datetime]] = mapped_column(DateTime) _table_args = (PrimaryKeyConstraint('path', 'state', name='BAD_PFNS_PK'), ForeignKeyConstraint(['account'], ['accounts.account'], name='BAD_PFNS_ACCOUNT_FK')) @@ -622,8 +624,8 @@ class QuarantinedReplica(BASE, ModelBase): bytes: Mapped[Optional[int]] = mapped_column(BigInteger) md5: Mapped[Optional[str]] = mapped_column(String(32)) adler32: Mapped[Optional[str]] = mapped_column(String(8)) - scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[Optional[str]] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[Optional[str]] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) _table_args = (PrimaryKeyConstraint('rse_id', 'path', name='QURD_REPLICAS_STATE_PK'), ForeignKeyConstraint(['rse_id'], ['rses.id'], name='QURD_REPLICAS_RSE_ID_FK'), Index('QUARANTINED_REPLICAS_PATH_IDX', 'path', 'rse_id', unique=True)) @@ -637,8 +639,8 @@ class QuarantinedReplicaHistory(BASE, ModelBase): bytes: Mapped[Optional[int]] = mapped_column(BigInteger) md5: Mapped[Optional[str]] = mapped_column(String(32)) adler32: Mapped[Optional[str]] = mapped_column(String(8)) - scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[Optional[str]] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[Optional[str]] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) deleted_at: Mapped[Optional[datetime]] = mapped_column(DateTime) __mapper_args__ = { 'primary_key': [rse_id, path] # Fake primary key for SQLA @@ -674,10 +676,10 @@ class DIDMetaConventionsConstraint(BASE, ModelBase): class DataIdentifierAssociation(BASE, ModelBase): """Represents the map between containers/datasets and files""" __tablename__ = 'contents' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # dataset scope - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # dataset name - child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Provenance scope - child_name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Provenance name + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # dataset scope + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # dataset name + child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Provenance scope + child_name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Provenance name did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='CONTENTS_DID_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -702,10 +704,10 @@ class DataIdentifierAssociation(BASE, ModelBase): class ConstituentAssociation(BASE, ModelBase): """Represents the map between archives and constituents""" __tablename__ = 'archive_contents' - child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Constituent file scope - child_name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Constituent file name - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Archive file scope - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Archive file name + child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Constituent file scope + child_name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Constituent file name + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Archive file scope + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Archive file name bytes: Mapped[Optional[int]] = mapped_column(BigInteger) adler32: Mapped[Optional[str]] = mapped_column(String(8)) md5: Mapped[Optional[str]] = mapped_column(String(32)) @@ -725,10 +727,10 @@ class ConstituentAssociation(BASE, ModelBase): class ConstituentAssociationHistory(BASE, ModelBase): """Represents the map history between archives and constituents""" __tablename__ = 'archive_contents_history' - child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Constituent file scope - child_name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Constituent file name - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Archive file scope - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Archive file name + child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Constituent file scope + child_name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Constituent file name + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Archive file scope + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Archive file name bytes: Mapped[Optional[int]] = mapped_column(BigInteger) adler32: Mapped[Optional[str]] = mapped_column(String(8)) md5: Mapped[Optional[str]] = mapped_column(String(32)) @@ -743,10 +745,10 @@ class ConstituentAssociationHistory(BASE, ModelBase): class DataIdentifierAssociationHistory(BASE, ModelBase): """Represents the map history between containers/datasets and files""" __tablename__ = 'contents_history' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # dataset scope - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # dataset name - child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Provenance scope - child_name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) # Provenance name + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # dataset scope + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # dataset name + child_scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) # Provenance scope + child_name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) # Provenance name did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='CONTENTS_HIST_DID_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -930,7 +932,7 @@ class RSEQoSAssociation(BASE, ModelBase): class AccountLimit(BASE, ModelBase): """Represents account limits""" __tablename__ = 'account_limits' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) bytes: Mapped[Optional[int]] = mapped_column(BigInteger) _table_args = (PrimaryKeyConstraint('account', 'rse_id', name='ACCOUNT_LIMITS_PK'), @@ -941,7 +943,7 @@ class AccountLimit(BASE, ModelBase): class AccountGlobalLimit(BASE, ModelBase): """Represents account limits""" __tablename__ = 'account_glob_limits' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) rse_expression: Mapped[str] = mapped_column(String(3000)) bytes: Mapped[Optional[int]] = mapped_column(BigInteger) _table_args = (PrimaryKeyConstraint('account', 'rse_expression', name='ACCOUNT_GLOBAL_LIMITS_PK'), @@ -951,7 +953,7 @@ class AccountGlobalLimit(BASE, ModelBase): class AccountUsage(BASE, ModelBase): """Represents account usage""" __tablename__ = 'account_usage' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) files: Mapped[int] = mapped_column(BigInteger) bytes: Mapped[int] = mapped_column(BigInteger) @@ -963,7 +965,7 @@ class AccountUsage(BASE, ModelBase): class AccountUsageHistory(BASE, ModelBase): """Represents account usage history""" __tablename__ = 'account_usage_history' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) files: Mapped[int] = mapped_column(BigInteger) bytes: Mapped[int] = mapped_column(BigInteger) @@ -974,8 +976,8 @@ class RSEFileAssociation(BASE, ModelBase): """Represents the map between locations and files""" __tablename__ = 'replicas' rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) bytes: Mapped[int] = mapped_column(BigInteger) md5: Mapped[Optional[str]] = mapped_column(String(32)) adler32: Mapped[Optional[str]] = mapped_column(String(8)) @@ -993,7 +995,7 @@ class RSEFileAssociation(BASE, ModelBase): CheckConstraint('STATE IS NOT NULL', name='REPLICAS_STATE_NN'), CheckConstraint('bytes IS NOT NULL', name='REPLICAS_SIZE_NN'), CheckConstraint('lock_cnt IS NOT NULL', name='REPLICAS_LOCK_CNT_NN'), - Index('REPLICAS_PATH_IDX', 'path', mysql_length=get_schema_value('NAME_LENGTH')), + Index('REPLICAS_PATH_IDX', 'path', mysql_length=common_schema.get_schema_value('NAME_LENGTH')), Index('REPLICAS_STATE_IDX', 'state'), Index('REPLICAS_RSE_ID_TOMBSTONE_IDX', 'rse_id', 'tombstone')) @@ -1001,8 +1003,8 @@ class RSEFileAssociation(BASE, ModelBase): class CollectionReplica(BASE, ModelBase): """Represents replicas for datasets/collections""" __tablename__ = 'collection_replicas' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='COLLECTION_REPLICAS_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1028,8 +1030,8 @@ class UpdatedCollectionReplica(BASE, ModelBase): """Represents updates to replicas for datasets/collections""" __tablename__ = 'updated_col_rep' id: Mapped[uuid.UUID] = mapped_column(GUID(), default=utils.generate_uuid) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='UPDATED_COL_REP_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1044,8 +1046,8 @@ class RSEFileAssociationHistory(BASE, ModelBase): """Represents a short history of the deleted replicas""" __tablename__ = 'replicas_history' rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) bytes: Mapped[int] = mapped_column(BigInteger) _table_args = (PrimaryKeyConstraint('rse_id', 'scope', 'name', name='REPLICAS_HIST_PK'), ForeignKeyConstraint(['rse_id'], ['rses.id'], name='REPLICAS_HIST_RSE_ID_FK'), @@ -1057,9 +1059,9 @@ class ReplicationRule(BASE, ModelBase): __tablename__ = 'rules' id: Mapped[uuid.UUID] = mapped_column(GUID(), default=utils.generate_uuid) subscription_id: Mapped[Optional[uuid.UUID]] = mapped_column(GUID()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='RULES_DID_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1130,9 +1132,9 @@ class ReplicationRuleHistoryRecent(BASE, ModelBase): __tablename__ = 'rules_hist_recent' id: Mapped[uuid.UUID] = mapped_column(GUID()) subscription_id: Mapped[Optional[uuid.UUID]] = mapped_column(GUID()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='RULES_HIST_RECENT_DIDTYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1178,9 +1180,9 @@ class ReplicationRuleHistory(BASE, ModelBase): __tablename__ = 'rules_history' id: Mapped[uuid.UUID] = mapped_column(GUID()) subscription_id: Mapped[Optional[uuid.UUID]] = mapped_column(GUID()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='RULES_HISTORY_DIDTYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1223,11 +1225,11 @@ class ReplicationRuleHistory(BASE, ModelBase): class ReplicaLock(BASE, ModelBase): """Represents replica locks""" __tablename__ = 'locks' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rule_id: Mapped[uuid.UUID] = mapped_column(GUID()) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) bytes: Mapped[Optional[int]] = mapped_column(BigInteger) state: Mapped[LockState] = mapped_column(Enum(LockState, name='LOCKS_STATE_CHK', create_constraint=True, @@ -1245,11 +1247,11 @@ class ReplicaLock(BASE, ModelBase): class DatasetLock(BASE, ModelBase): """Represents dataset locks""" __tablename__ = 'dataset_locks' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rule_id: Mapped[uuid.UUID] = mapped_column(GUID()) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) state: Mapped[LockState] = mapped_column(Enum(LockState, name='DATASET_LOCKS_STATE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), @@ -1271,7 +1273,7 @@ class UpdatedAccountCounter(BASE, ModelBase): """Represents the recently updated Account counters""" __tablename__ = 'updated_account_counters' id: Mapped[uuid.UUID] = mapped_column(GUID(), default=utils.generate_uuid) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) files: Mapped[int] = mapped_column(BigInteger) bytes: Mapped[int] = mapped_column(BigInteger) @@ -1289,8 +1291,8 @@ class Request(BASE, ModelBase): create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestType.TRANSFER) - scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[Optional[str]] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[Optional[str]] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='REQUESTS_DIDTYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), @@ -1322,7 +1324,7 @@ class Request(BASE, ModelBase): estimated_transferred_at: Mapped[Optional[datetime]] = mapped_column(DateTime) staging_started_at: Mapped[Optional[datetime]] = mapped_column(DateTime) staging_finished_at: Mapped[Optional[datetime]] = mapped_column(DateTime) - account: Mapped[Optional[InternalAccount]] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[Optional[InternalAccount]] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) requested_at: Mapped[Optional[datetime]] = mapped_column(DateTime) last_processed_by: Mapped[Optional[str]] = mapped_column(String(64)) last_processed_at: Mapped[Optional[datetime]] = mapped_column(DateTime) @@ -1364,8 +1366,8 @@ class RequestHistory(BASE, ModelBase): create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestType.TRANSFER) - scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[Optional[str]] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[Optional[InternalScope]] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[Optional[str]] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='REQUESTS_HIST_DIDTYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), @@ -1397,7 +1399,7 @@ class RequestHistory(BASE, ModelBase): estimated_transferred_at: Mapped[Optional[datetime]] = mapped_column(DateTime) staging_started_at: Mapped[Optional[datetime]] = mapped_column(DateTime) staging_finished_at: Mapped[Optional[datetime]] = mapped_column(DateTime) - account: Mapped[Optional[InternalAccount]] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[Optional[InternalAccount]] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) requested_at: Mapped[Optional[datetime]] = mapped_column(DateTime) priority: Mapped[Optional[int]] = mapped_column(Integer) transfertool: Mapped[Optional[str]] = mapped_column(String(64)) @@ -1412,8 +1414,8 @@ class Source(BASE, ModelBase): """Represents source files for transfers""" __tablename__ = 'sources' request_id: Mapped[uuid.UUID] = mapped_column(GUID()) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) dest_rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) url: Mapped[Optional[str]] = mapped_column(String(2048)) @@ -1434,8 +1436,8 @@ class SourceHistory(BASE, ModelBase): """Represents history of source files for transfers""" __tablename__ = 'sources_history' request_id: Mapped[uuid.UUID] = mapped_column(GUID()) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) dest_rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) url: Mapped[Optional[str]] = mapped_column(String(2048)) @@ -1492,7 +1494,7 @@ class Subscription(BASE, ModelBase): values_callable=lambda obj: [e.value for e in obj]), default=SubscriptionState.ACTIVE) last_processed: Mapped[Optional[datetime]] = mapped_column(DateTime, default=datetime.utcnow()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) lifetime: Mapped[Optional[datetime]] = mapped_column(DateTime) comments: Mapped[Optional[str]] = mapped_column(String(4000)) retroactive: Mapped[bool] = mapped_column(Boolean(name='SUBSCRIPTIONS_RETROACTIVE_CHK', create_constraint=True), @@ -1519,7 +1521,7 @@ class SubscriptionHistory(BASE, ModelBase): values_callable=lambda obj: [e.value for e in obj]), default=SubscriptionState.ACTIVE) last_processed: Mapped[Optional[datetime]] = mapped_column(DateTime, default=datetime.utcnow()) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) lifetime: Mapped[Optional[datetime]] = mapped_column(DateTime) comments: Mapped[Optional[str]] = mapped_column(String(4000)) retroactive: Mapped[bool] = mapped_column(Boolean(name='SUBS_HISTORY_RETROACTIVE_CHK', create_constraint=True), @@ -1532,7 +1534,7 @@ class Token(BASE, ModelBase): """Represents the authentication tokens and their lifetime""" __tablename__ = 'tokens' token: Mapped[str] = mapped_column(String(3072)) # account-identity-appid-uuid -> max length: (+ 30 1 255 1 32 1 32) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) refresh_token: Mapped[Optional[str]] = mapped_column(String(3072), default=None) refresh: Mapped[bool] = mapped_column(Boolean(name='TOKENS_REFRESH_CHK', create_constraint=True), default=False) @@ -1553,7 +1555,7 @@ class Token(BASE, ModelBase): class OAuthRequest(BASE, ModelBase): """Represents the authentication session parameters of OAuth 2.0 requests""" __tablename__ = 'oauth_requests' - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) state: Mapped[str] = mapped_column(String(50)) nonce: Mapped[Optional[str]] = mapped_column(String(50)) access_msg: Mapped[Optional[str]] = mapped_column(String(2048)) @@ -1638,7 +1640,7 @@ class Heartbeat(BASE, ModelBase): class NamingConvention(BASE, ModelBase): """Represents naming conventions for name within a scope""" __tablename__ = 'naming_conventions' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) regexp: Mapped[Optional[str]] = mapped_column(String(255)) convention_type: Mapped[KeyType] = mapped_column(Enum(KeyType, name='CVT_TYPE_CHK', create_constraint=True, @@ -1651,12 +1653,12 @@ class LifetimeException(BASE, ModelBase): """Represents the exceptions to the lifetime model""" __tablename__ = 'lifetime_except' id: Mapped[uuid.UUID] = mapped_column(GUID(), default=utils.generate_uuid) - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='LIFETIME_EXCEPT_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) pattern: Mapped[Optional[str]] = mapped_column(String(255)) comments: Mapped[Optional[str]] = mapped_column(String(4000)) state: Mapped[LifetimeExceptionsState] = mapped_column(Enum(LifetimeExceptionsState, name='LIFETIME_EXCEPT_STATE_CHK', @@ -1682,9 +1684,9 @@ class VO(BASE, ModelBase): class DidFollowed(BASE, ModelBase): """Represents the datasets followed by a user""" __tablename__ = 'dids_followed' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='DIDS_FOLLOWED_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) @@ -1700,9 +1702,9 @@ class DidFollowed(BASE, ModelBase): class FollowEvent(BASE, ModelBase): """Represents the events affecting the datasets which are followed""" __tablename__ = 'dids_followed_events' - scope: Mapped[InternalScope] = mapped_column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) - name: Mapped[str] = mapped_column(String(get_schema_value('NAME_LENGTH'))) - account: Mapped[InternalAccount] = mapped_column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) + scope: Mapped[InternalScope] = mapped_column(InternalScopeString(common_schema.get_schema_value('SCOPE_LENGTH'))) + name: Mapped[str] = mapped_column(String(common_schema.get_schema_value('NAME_LENGTH'))) + account: Mapped[InternalAccount] = mapped_column(InternalAccountString(common_schema.get_schema_value('ACCOUNT_LENGTH'))) did_type: Mapped[DIDType] = mapped_column(Enum(DIDType, name='DIDS_FOLLOWED_EVENTS_TYPE_CHK', create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) diff --git a/lib/rucio/db/sqla/util.py b/lib/rucio/db/sqla/util.py index e71782146f..a6f39050e2 100644 --- a/lib/rucio/db/sqla/util.py +++ b/lib/rucio/db/sqla/util.py @@ -30,10 +30,10 @@ from sqlalchemy.sql.ddl import DropSchema from sqlalchemy.sql.expression import select, text +import rucio.common.schema from rucio import alembicrevision from rucio.common.cache import MemcacheRegion from rucio.common.config import config_get, config_get_list -from rucio.common.schema import get_schema_value from rucio.common.types import InternalAccount, LoggerFunction from rucio.common.utils import generate_uuid from rucio.db.sqla import models @@ -491,8 +491,8 @@ def create_scope_name_table(self, logger: LoggerFunction = logging.log) -> type[ """ columns = [ - Column("scope", InternalScopeString(get_schema_value('SCOPE_LENGTH'))), - Column("name", String(get_schema_value('NAME_LENGTH'))), + Column("scope", InternalScopeString(rucio.common.schema.get_schema_value('SCOPE_LENGTH'))), + Column("name", String(rucio.common.schema.get_schema_value('NAME_LENGTH'))), ] return self.create_temp_table( 'TEMPORARY_SCOPE_NAME', @@ -507,10 +507,10 @@ def create_association_table(self, logger: LoggerFunction = logging.log) -> type """ columns = [ - Column("scope", InternalScopeString(get_schema_value('SCOPE_LENGTH'))), - Column("name", String(get_schema_value('NAME_LENGTH'))), - Column("child_scope", InternalScopeString(get_schema_value('SCOPE_LENGTH'))), - Column("child_name", String(get_schema_value('NAME_LENGTH'))), + Column("scope", InternalScopeString(rucio.common.schema.get_schema_value('SCOPE_LENGTH'))), + Column("name", String(rucio.common.schema.get_schema_value('NAME_LENGTH'))), + Column("child_scope", InternalScopeString(rucio.common.schema.get_schema_value('SCOPE_LENGTH'))), + Column("child_name", String(rucio.common.schema.get_schema_value('NAME_LENGTH'))), ] return self.create_temp_table( 'TEMPORARY_ASSOCIATION', diff --git a/lib/rucio/rse/rsemanager.py b/lib/rucio/rse/rsemanager.py index cb5868db1e..f37c58a5e1 100644 --- a/lib/rucio/rse/rsemanager.py +++ b/lib/rucio/rse/rsemanager.py @@ -21,7 +21,6 @@ from rucio.common import constants, exception, types, utils from rucio.common.config import config_get_int -from rucio.common.constants import RSE_SUPPORTED_PROTOCOL_OPERATIONS from rucio.common.constraints import STRING_TYPES from rucio.common.logging import formatted_logger from rucio.common.utils import GLOBALLY_SUPPORTED_CHECKSUMS, make_valid_did @@ -133,7 +132,7 @@ def _get_possible_protocols(rse_settings: types.RSESettingsDict, operation, sche def get_protocols_ordered(rse_settings: types.RSESettingsDict, operation, scheme=None, domain='wan', impl=None): - if operation not in RSE_SUPPORTED_PROTOCOL_OPERATIONS: + if operation not in constants.RSE_SUPPORTED_PROTOCOL_OPERATIONS: raise exception.RSEOperationNotSupported('Operation %s is not supported' % operation) if domain and domain not in utils.rse_supported_protocol_domains(): @@ -145,7 +144,7 @@ def get_protocols_ordered(rse_settings: types.RSESettingsDict, operation, scheme def select_protocol(rse_settings: types.RSESettingsDict, operation, scheme=None, domain='wan'): - if operation not in RSE_SUPPORTED_PROTOCOL_OPERATIONS: + if operation not in constants.RSE_SUPPORTED_PROTOCOL_OPERATIONS: raise exception.RSEOperationNotSupported('Operation %s is not supported' % operation) if domain and domain not in utils.rse_supported_protocol_domains(): @@ -173,7 +172,7 @@ def create_protocol(rse_settings: types.RSESettingsDict, operation, scheme=None, # Verify feasibility of Protocol operation = operation.lower() - if operation not in RSE_SUPPORTED_PROTOCOL_OPERATIONS: + if operation not in constants.RSE_SUPPORTED_PROTOCOL_OPERATIONS: raise exception.RSEOperationNotSupported('Operation %s is not supported' % operation) if domain and domain not in utils.rse_supported_protocol_domains():