Skip to content

Commit

Permalink
feature/mx-1562 code maintenance (#82)
Browse files Browse the repository at this point in the history
# PR Context

- preparation for mx-1381 and to keep
#69 smaller
- already removing public-api module for mx-1562, not closing that
ticket yet though

# Changes

- update cruft and dev dependencies
- randomize test order by default

# Removed

- remove `mex.common.public_api` module and the correlating sinks
- remove `PathWrapper.resolve` and `PathWrapper.raw` methods

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
cutoffthetop and dependabot[bot] authored Feb 22, 2024
1 parent 417250d commit 9ec130c
Show file tree
Hide file tree
Showing 40 changed files with 251 additions and 1,650 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"checkout": null,
"commit": "d1a461de3c7ff099045b71a156ad667887c32368",
"commit": "6067fc53d1335a9bda900c5eff8dbf1c42bfe4ca",
"context": {
"cookiecutter": {
"project_name": "common",
Expand Down
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.2.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -20,6 +20,12 @@ repos:
exclude: .cruft.json
- id: check-yaml
name: yaml
- id: end-of-file-fixer
name: eof
- id: trailing-whitespace
name: whitespaces
- id: fix-byte-order-marker
name: byte-order
- repo: https://github.com/python-poetry/poetry
rev: 1.7.1
hooks:
Expand Down
45 changes: 19 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security

## [0.19.4] - 2024-02-15

### Added
## [0.20.0] - 2024-02-22

### Changes

- update cruft and minor dependencies

### Deprecated
- update cruft and dev dependencies
- randomize test order by default

### Removed

- date-time format validation for mapping model generation
- remove `mex.common.public_api` module and the correlating sinks
- remove `PathWrapper.resolve` and `PathWrapper.raw` methods

### Fixed

### Security
- remove `pytest.mark` from fixture in `mex.common.testing.plugin`

## [0.19.3] - 2024-02-06
## [0.19.4] - 2024-02-15

### Added
### Changes

- update cruft and minor dependencies

### Removed

- date-time format validation for mapping model generation

## [0.19.3] - 2024-02-06

### Changes

- update cruft to apply new workflow trigger config
- update poetry and pre-commit dependencies

### Deprecated

### Removed

### Fixed
- fix mex mapping model name

### Security
- fix mex mapping model name

## [0.19.2] - 2024-02-02

Expand All @@ -66,14 +67,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `mex.bat test` uses random order and xdist plugins by default

### Deprecated

### Removed

### Fixed

### Security

## [0.19.1] - 2024-01-19

### Added
Expand Down Expand Up @@ -133,8 +126,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated

- deprecate `MExModel.get_entity_type`, use `cls.__name__` instead
- deprecate `mex.common.models.MODEL_CLASSES[_BY_ENTITY_TYPE]`, use the more precise lists or dicts like `EXTRACTED_MODEL_CLASSES_BY_NAME` instead

- deprecate `mex.common.models.MODEL_CLASSES[_BY_ENTITY_TYPE]`,
use the more precise lists or dicts like `EXTRACTED_MODEL_CLASSES_BY_NAME` instead

## [0.17.1] - 2023-12-20

Expand Down
5 changes: 2 additions & 3 deletions mex.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ echo linting all files
pre-commit run --all-files
if %errorlevel% neq 0 exit /b %errorlevel%

@REM run the pytest test suite with unit and integration tests in random order
@REM distributed across all available CPU cores
@REM run pytest unit and integration tests distributed across available cores
echo running all tests
poetry run pytest --random-order-bucket=global --numprocesses=auto --dist=worksteal
poetry run pytest --numprocesses=auto --dist=worksteal
exit /b %errorlevel%


Expand Down
2 changes: 1 addition & 1 deletion mex/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def __str__(self) -> str:
"""Format this exception as a string for logging."""
return (
f"{self.__class__.__name__}: "
f"{(', '.join((str(arg) for arg in self.args)))} "
f"{(', '.join(str(arg) for arg in self.args))} "
)


Expand Down
20 changes: 10 additions & 10 deletions mex/common/ldap/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
Helper extractor to extract data from Lightweight Directory Access Protocol (LDAP).
Helper extractor to extract data from Lightweight Directory Access Protocol (LDAP).

Common use cases:
- extract employee accounts of your organization
- extract employee accounts of your organization
- extract functional accounts of your organization

Possible queries are for example the account name, surname, given name, or email.
Possible queries are for example the account name, surname, given name, or email.

# Configuration

For configuring the ldap connection, set the settings parameter `ldap_url`
(see `mex.common.settings` for further info) to an LDAP url (see
[LDAP URL definition](https://datatracker.ietf.org/doc/html/rfc2255#section-3) for
For configuring the ldap connection, set the settings parameter `ldap_url`
(see `mex.common.settings` for further info) to an LDAP url (see
[LDAP URL definition](https://datatracker.ietf.org/doc/html/rfc2255#section-3) for
further information).

# Extracting data

Use the `LDAPConnector` from the `ldap.connector` module to extract data.
Use the `LDAPConnector` from the `ldap.connector` module to extract data.

# Transforming data

The module `ldap.transform` contains functions for transforming LDAP data into MEx
The module `ldap.transform` contains functions for transforming LDAP data into MEx
models.

The `mex_person.stableTargetId` attribute can be used in any entity that requires a
The `mex_person.stableTargetId` attribute can be used in any entity that requires a
`PersonID`.

# Convenience Functions

The module `ldap.extract` holds convenience functions, e.g. for build a mapping from
The module `ldap.extract` holds convenience functions, e.g. for build a mapping from
query strings to `stableTargetId`s.
2 changes: 1 addition & 1 deletion mex/common/ldap/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _fetch(
if attributes := entry.get("attributes"):
yield model_cls.model_validate(attributes)

@cache
@cache # noqa: B019
def _paged_ldap_search(
self, fields: tuple[str], search_filter: str, search_base: str
) -> list[dict[str, str]]:
Expand Down
8 changes: 4 additions & 4 deletions mex/common/organigram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Common use cases:

# Configuration

The extractor reads data from a json file, whose path is set with the settings parameter
The extractor reads data from a json file, whose path is set with the settings parameter
`organigram_path` (see `mex.common.settings` for further info).

# Extracting data
Expand All @@ -16,15 +16,15 @@ The module `organigram.extract` contains functions for data extraction.

The module `organigram.transform` contains functions for data transformation.

Use the `stableTargetId` attribute of the transformed objects to set attributes
Use the `stableTargetId` attribute of the transformed objects to set attributes
requiring an `OrganizationalUnitID`.

# Convenience Functions

The module `organigram.extract` holds convenience functions, e.g. for building a mapping
The module `organigram.extract` holds convenience functions, e.g. for building a mapping
from email addresses or synonyms to `ExtractedOrganizationalUnit`.

# json file format

See example file in `assets/raw-data/organigram/organizational_units.json`.
See example file in `assets/raw-data/organigram/organizational_units.json`.
For mandatory / optional attributes, see model in `mex/common/organigram/models.py`.
2 changes: 1 addition & 1 deletion mex/common/organigram/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def extract_organigram_units() -> Generator[OrganigramUnit, None, None]:
Generator for organigram units
"""
settings = BaseSettings.get()
with open(settings.organigram_path, "r") as fh:
with open(settings.organigram_path) as fh:
for raw in json.load(fh):
yield OrganigramUnit.model_validate(raw)

Expand Down
2 changes: 1 addition & 1 deletion mex/common/primary_source/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def extract_seed_primary_sources() -> Generator[SeedPrimarySource, None, None]:
Generator for seed primary sources
"""
settings = BaseSettings.get()
with open(settings.primary_sources_path, "r") as fh:
with open(settings.primary_sources_path) as fh:
for raw in json.load(fh):
yield SeedPrimarySource.model_validate(raw)
Empty file removed mex/common/public_api/__init__.py
Empty file.
Loading

0 comments on commit 9ec130c

Please sign in to comment.