From d3ec3d6aa0cbc37f12de2f7ed637cfb1971ce4d6 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Thu, 25 Apr 2024 13:40:17 +0200 Subject: [PATCH 1/3] chore(deps): use json-arrays instead of json-streams json-streams has changed name to json-arrays --- karp/cliapp/subapps/entries_subapp.py | 20 ++++++++++---------- karp/cliapp/subapps/query_subapp.py | 4 ++-- karp/cliapp/subapps/resource_subapp.py | 2 +- pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/karp/cliapp/subapps/entries_subapp.py b/karp/cliapp/subapps/entries_subapp.py index 1f001528..bc63a3dd 100644 --- a/karp/cliapp/subapps/entries_subapp.py +++ b/karp/cliapp/subapps/entries_subapp.py @@ -5,8 +5,8 @@ from typing import Iterable, Optional -import json_streams -import json_streams.jsonlib +import json_arrays +import json_arrays.jsonlib from sb_json_tools import jt_val import typer @@ -40,7 +40,7 @@ def add_entries_to_resource( entry_commands = inject_from_ctx(EntryCommands, ctx) user = user or "local admin" message = message or "imported through cli" - entries = tqdm(json_streams.load_from_file(data), desc="Adding", unit=" entries") + entries = tqdm(json_arrays.load_from_file(data), desc="Adding", unit=" entries") if chunked: entry_commands.add_entries_in_chunks( resource_id=resource_id, @@ -74,7 +74,7 @@ def import_entries_to_resource( entry_commands = inject_from_ctx(EntryCommands, ctx) user = user or "local admin" message = message or "imported through cli" - entries = tqdm(json_streams.load_from_file(data), desc="Importing", unit=" entries") + entries = tqdm(json_arrays.load_from_file(data), desc="Importing", unit=" entries") if chunked: entry_commands.import_entries_in_chunks( resource_id=resource_id, @@ -114,7 +114,7 @@ def export_entries( "exporting entries", extra={"resource_id": resource_id, "type(all_entries)": type(all_entries)}, ) - json_streams.dump( + json_arrays.dump( (entry.dict() for entry in all_entries), output, ) @@ -138,7 +138,7 @@ def batch_entries( """ logger.info("run entries command in batch") entry_commands = inject_from_ctx(EntryCommands, ctx) # type: ignore[type-abstract] - for cmd_outer in json_streams.load_from_file(data): + for cmd_outer in json_arrays.load_from_file(data): cmd = cmd_outer["cmd"] command_type = cmd["cmdtype"] del cmd["cmdtype"] @@ -206,7 +206,7 @@ def validate_entries( raise typer.Exit(301) if config_path: - config = json_streams.jsonlib.load_from_file(config_path) + config = json_arrays.jsonlib.load_from_file(config_path) elif resource_id_raw: repo = inject_from_ctx(ResourceQueries, ctx=ctx) if resource := repo.by_resource_id(resource_id_raw): @@ -223,12 +223,12 @@ def validate_entries( error_code = 0 - entries: Iterable[dict] = json_streams.load_from_file(path, use_stdin_as_default=True) + entries: Iterable[dict] = json_arrays.load_from_file(path, use_stdin_as_default=True) if as_import: entries = (import_entry["entry"] for import_entry in entries) - with json_streams.sink_from_file( + with json_arrays.sink_from_file( err_output, use_stderr_as_default=True - ) as error_sink, json_streams.sink_from_file( + ) as error_sink, json_arrays.sink_from_file( output, use_stdout_as_default=True ) as correct_sink: error_counter = Counter(error_sink) diff --git a/karp/cliapp/subapps/query_subapp.py b/karp/cliapp/subapps/query_subapp.py index b728448d..eb11b788 100644 --- a/karp/cliapp/subapps/query_subapp.py +++ b/karp/cliapp/subapps/query_subapp.py @@ -1,7 +1,7 @@ from pathlib import Path # noqa: I001 from typing import Optional -import json_streams +import json_arrays import typer from karp import search @@ -20,7 +20,7 @@ def resource( ): search_service = inject_from_ctx(EsSearchService, ctx) query_request = search.QueryRequest(resource_ids=[resource_id]) - json_streams.dump_to_file( + json_arrays.dump_to_file( search_service.query(query_request), output, use_stdout_as_default=True, diff --git a/karp/cliapp/subapps/resource_subapp.py b/karp/cliapp/subapps/resource_subapp.py index 16ff11d5..de1369c2 100644 --- a/karp/cliapp/subapps/resource_subapp.py +++ b/karp/cliapp/subapps/resource_subapp.py @@ -3,7 +3,7 @@ from typing import Callable, List, Optional, TypeVar import typer -from json_streams import jsonlib +from json_arrays import jsonlib from tabulate import tabulate from karp.foundation.value_objects import UniqueIdStr, unique_id diff --git a/pyproject.toml b/pyproject.toml index ba000639..2787f302 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,6 @@ elasticsearch-dsl = "^8" environs = "^9.3.4" fastapi = "^0.89.0" injector = "^0.20.1" -json-streams = "^0.12.0" mysqlclient = { version = "^2.1.1", optional = true } pydantic = "^1.10.2" pyjwt = { version = "^2.6.0", extras = ["crypto"] } @@ -60,6 +59,7 @@ ulid-py = "^1.1.0" urllib3 = "^1.26.13" asgi-matomo = "^0.4.1" frozendict = "^2.4" +json-arrays = "^0.14.1" [tool.poetry.extras] mysql = ["mysqlclient", "PyMySQL", "aiomysql"] From d48ac7f2057a03622ef75452f980dd8da345faf7 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Thu, 25 Apr 2024 13:43:55 +0200 Subject: [PATCH 2/3] ci: adjust ci workflows --- .github/workflows/backend-checks.yml | 13 ++++++++++--- .github/workflows/backend-tests.yml | 16 ++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/backend-checks.yml b/.github/workflows/backend-checks.yml index f251a9f8..0bc74054 100644 --- a/.github/workflows/backend-checks.yml +++ b/.github/workflows/backend-checks.yml @@ -7,13 +7,20 @@ on: tags-ignore: - v* paths: - - 'karp-backend/**' - - '!karp-backend/README.md' + - 'karp/**' + - 'tests/**' + - 'grammars/**' + - 'assets/**' + - '*.toml' pull_request: branches: - '**/*' paths: - - 'karp-backend/**' + - 'karp/**' + - 'tests/**' + - 'grammars/**' + - 'assets/**' + - '*.toml' workflow_dispatch: env: diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml index fc8de6a5..5059389c 100644 --- a/.github/workflows/backend-tests.yml +++ b/.github/workflows/backend-tests.yml @@ -5,16 +5,20 @@ on: branches: - "**/*" paths: - - 'karp-backend/**/*.py' - - 'karp-backend/pyproject.toml' - - 'karp-lex-core/**/*.py' + - 'karp/**' + - 'tests/**' + - 'grammars/**' + - 'assets/**' + - '*.toml' pull_request: branches: - "**/*" paths: - - 'karp-backend/**/*.py' - - 'karp-backend/pyproject.toml' - - 'karp-lex-core/**/*.py' + - 'karp/**' + - 'tests/**' + - 'grammars/**' + - 'assets/**' + - '*.toml' workflow_dispatch: env: From 71c173657a2eb11dd59258ef8ceafc756a7f8cab Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Thu, 25 Apr 2024 13:49:19 +0200 Subject: [PATCH 3/3] ci: add dependabot config --- .github/dependabot.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..aa363d38 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,25 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + ignore: + - dependency-name: "*" + # patch and minor updates don't matter for libraries as consumers of this library build + # with their own lockfile, rather than the version specified in this library's lockfile + # remove this ignore rule if your package has binaries to ensure that the binaries are + # built with the exact set of dependencies and those are up to date. + update-types: + - "version-update:semver-patch" + - "version-update:semver-minor"