Skip to content

Commit

Permalink
Merge pull request #251
Browse files Browse the repository at this point in the history
  • Loading branch information
majsan committed Apr 26, 2024
2 parents 059ce2d + 71c1736 commit 2b02c5b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 10 additions & 3 deletions .github/workflows/backend-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions karp/cliapp/subapps/entries_subapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand All @@ -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"]
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions karp/cliapp/subapps/query_subapp.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion karp/cliapp/subapps/resource_subapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"]
Expand Down

0 comments on commit 2b02c5b

Please sign in to comment.