Skip to content

Commit 399bd20

Browse files
committed
feature(actions): Should Build without Database.
Added `include` to `db.Config` because the database should not be used in builds (for now). Added banner, svg captures, and japanese figure. Added more notes on NVIM improvements.
1 parent bb31225 commit 399bd20

8 files changed

Lines changed: 564 additions & 104 deletions

File tree

.github/workflows/commit_checks.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ jobs:
111111
echo "ACEDERBERG_IO_ENV=ci" >> "GITHUB_ENV"
112112
113113
source .venv/bin/activate
114-
poetry run acederbergio db config
115114
poetry run coverage run -m pytest
116115
poetry run coverage html
117116
- name: Upload Coverage Report.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ blog/projects/blog/typedoc
4646
blog/projects/blog/quartodoc
4747
blog/dsa/leetcode/calendar_2/_oops_files/
4848
.env.actions
49+
blog/posts/keywords/*.svg

acederbergio/db.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ def check_object_id(value) -> str | None:
4242
pydantic.Field(default=None),
4343
pydantic.BeforeValidator(check_object_id),
4444
]
45-
FlagURL = Annotated[str, typer.Option("--mongodb-url"), pydantic.Field(URL)]
45+
FlagURL = Annotated[
46+
pydantic.MongoDsn, typer.Option("--mongodb-url"), pydantic.Field(URL)
47+
]
4648
FlagDatabase = Annotated[str, pydantic.Field(DATABASE)]
4749

4850

49-
def create_client(*, _mongodb_url: str | None = None, cls: Type = MongoClient):
50-
mongodb_url = env.require("mongodb_url", _mongodb_url)
51+
def create_client(
52+
*, _mongodb_url: pydantic.MongoDsn | str | None = None, cls: Type = MongoClient
53+
):
54+
mongodb_url = env.require("mongodb_url", str(_mongodb_url))
5155
return cls(mongodb_url, server_api=ServerApi("1"))
5256

5357

@@ -64,6 +68,27 @@ class Config(ysp.BaseYamlSettings):
6468

6569
database: FlagDatabase
6670
url: FlagURL
71+
include: Annotated[
72+
bool,
73+
pydantic.Field(
74+
default=env.ENV == "ci",
75+
description="""
76+
When mongodb is not required (e.g. during builds) use this to
77+
run without it. Some documents using this code do not need mongodb
78+
for one off renders. To set this, do
79+
80+
.. code:: python
81+
82+
ACEDERBERG_IO_MONGODB_INCLUDE=false
83+
84+
and verify:
85+
86+
.. code:: shell
87+
88+
acederbergio db config
89+
""",
90+
),
91+
]
6792

6893
def create_client(self) -> MongoClient:
6994
return create_client(_mongodb_url=self.url)

acederbergio/pdf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def compare(cls, left: "Metrics", right: "Metrics") -> Self:
8484
)
8585

8686

87-
class Metrics(util.HasTimestamp):
87+
class Metrics(util.HasTimestamp, db.HasMongoId):
8888
"""
8989
**RAKE** metrics for a piece of text.
9090
@@ -203,6 +203,9 @@ async def lazy(
203203
force: bool = False,
204204
) -> Self:
205205

206+
# if db is None:
207+
# return cls.create(cls.createDF(text), text=text, metadata=metadata)
208+
206209
collection = db[cls._collection]
207210
res = await collection.find_one(cls.match_text(text)["$match"])
208211
if not force and res is not None:
@@ -469,7 +472,7 @@ def __init__(
469472
@classmethod
470473
def resolveText(cls, text: FlagText, _file: FlagFile) -> tuple[str, dict[str, str]]:
471474
if text is None and _file is None:
472-
util.CONSOLE.print("[red]Failed to determine text.")
475+
util.CONSOLE.print("[red]One of `--text` or `--file` is required.")
473476
raise typer.Exit(3)
474477

475478
metadata = dict(origin="cli", origin_file="pdf.py")

acederbergio/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def print_yaml(
8181
rule_title: str = "",
8282
rule_kwargs: dict[str, Any] = dict(),
8383
is_complex: bool = False,
84+
console: rich.console.Console = CONSOLE,
8485
**kwargs_model_dump,
8586
) -> rich.syntax.Syntax | None:
8687
if items:
@@ -109,9 +110,9 @@ def print_yaml(
109110
)
110111

111112
if rule_title or rule_kwargs:
112-
CONSOLE.rule(rule_title, **rule_kwargs)
113+
console.rule(rule_title, **rule_kwargs)
113114

114-
CONSOLE.print(s)
115+
console.print(s)
115116
return s
116117

117118

0 commit comments

Comments
 (0)