Skip to content

Commit

Permalink
refactor: fix import errors after folder restructure (#202)
Browse files Browse the repository at this point in the history
Auto-created

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
MartinBernstorff and github-actions authored Nov 19, 2023
1 parent 6a9e7fb commit 5680ad9
Show file tree
Hide file tree
Showing 36 changed files with 152 additions and 137 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stalebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
steps:
- uses: actions/stale@v6
with:
days-before-issue-stale: 14
days-before-issue-close: 7
days-before-issue-stale: 9999
days-before-issue-close: 9999
stale-issue-message: "This issue is stale because it has been open for 14 days with no activity. Feel free to either 1) remove the stale label or 2) comment. If nothing happens, this will be closed in 7 days."
close-issue-message: "This issue was closed automatically. Feel free to re-open it if it's important."
days-before-pr-stale: 2
Expand Down
11 changes: 0 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,5 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"explorer.excludeGitIgnore": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/BUILD": true,
"*.egg-info": true,
"*.pytest_cache": true,
},
"python.analysis.diagnosticMode": "workspace"
}
12 changes: 8 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
SRC_PATH = personal_mnemonic_medium

# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/205 Decrease makefile verbosity
# E.g. entering/leaving directory
# Or showing each command when running make pr

deploy:
./docker_cmd.sh

Expand All @@ -14,24 +18,24 @@ install:
pip install -e .

test: ## Run tests
pytest personal_mnemonic_medium/tests
pytest personal_mnemonic_medium

test-cov: ## Run tests with coverage
# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/209 Fix coverage and add it to make pr
pytest --cov=personal_mnemonic_medium --cov-report=term-missing personal_mnemonic_medium/tests
pytest --cov=personal_mnemonic_medium --cov-report=term-missing personal_mnemonic_medium

lint: ## Format code
ruff format .
ruff . --fix \
--extend-select F401 \
--extend-select F841

type-check: ## Type-check code
types: ## Type-check code
pyright $(SRC_PATH)

validate: ## Run all checks
make lint
make type-check
make types
make test

merge-main:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from collections.abc import Sequence
from pathlib import Path

from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)


class DocumentFactory(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

from tqdm import tqdm

from personal_mnemonic_medium.note_factories.base import (
from personal_mnemonic_medium.data_access.document_ingesters.base import (
DocumentFactory,
)
from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)


class MarkdownNoteFactory(DocumentFactory):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@

import genanki

from personal_mnemonic_medium.exporters.markdown_to_html.html_compiler import (
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)
from personal_mnemonic_medium.domain.markdown_to_html import (
compile_field,
)
from personal_mnemonic_medium.exporters.url_generators.obsidian_url import (
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)
from personal_mnemonic_medium.domain.url_generators.obsidian_url import (
get_obsidian_url,
)
from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt


class AnkiCard(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

import genanki

from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.anki.globals import CONFIG
from personal_mnemonic_medium.exporters.markdown_to_html.html_compiler import (
from personal_mnemonic_medium.data_access.exporters.anki.globals import (
CONFIG,
)
from personal_mnemonic_medium.domain.markdown_to_html import (
compile_field,
)
from personal_mnemonic_medium.exporters.url_generators.obsidian_url import (
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)
from personal_mnemonic_medium.domain.url_generators.obsidian_url import (
get_obsidian_url,
)
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt
from personal_mnemonic_medium.utils.hasher import simple_hash


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
from pathlib import Path

import genanki
from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.anki.globals import CONFIG
from personal_mnemonic_medium.exporters.markdown_to_html.html_compiler import (
from personal_mnemonic_medium.domain.markdown_to_html import (
compile_field,
)
from personal_mnemonic_medium.exporters.url_generators.obsidian_url import (
from personal_mnemonic_medium.domain.url_generators.obsidian_url import (
get_obsidian_url,
)
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)
from personal_mnemonic_medium.utils.hasher import simple_hash
from personal_mnemonic_medium.exporters.anki.globals import CONFIG # noqa
from personal_mnemonic_medium.data_access.exporters.anki.globals import ( # noqa
CONFIG,
)


class AnkiQA(AnkiCard):
Expand All @@ -39,12 +42,13 @@ def genanki_model(self) -> genanki.Model:
global CONFIG # noqa
return genanki.Model(
model_id=simple_hash(CONFIG["card_model_name_qa"]), # type: ignore
name=CONFIG["card_model_name_qa"],
fields=CONFIG["card_model_fields_qa"],
templates=CONFIG["card_model_template_qa"],
name=CONFIG["card_model_name_qa"], # type: ignore
fields=CONFIG["card_model_fields_qa"], # type: ignore
templates=CONFIG["card_model_template_qa"], # type: ignore
css=CONFIG["card_model_css"], # type: ignore
model_type=0,
)
# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/203 Refactor the CONFIG to be a dataclass

@property
def card_uuid(self) -> int:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
from collections.abc import Sequence
from pathlib import Path

from personal_mnemonic_medium.card_pipeline import CardPipeline
from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.document_ingesters.base import (
DocumentFactory,
)
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)
from personal_mnemonic_medium.data_access.document_ingesters.markdown_ingester import (
MarkdownNoteFactory,
)
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.anki.card_types.qa import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.qa import (
AnkiQA,
)
from personal_mnemonic_medium.exporters.anki.package_generator import (
from personal_mnemonic_medium.data_access.exporters.anki.package_generator import (
AnkiPackageGenerator,
)
from personal_mnemonic_medium.exporters.base import CardExporter
from personal_mnemonic_medium.note_factories.base import (
DocumentFactory,
)
from personal_mnemonic_medium.note_factories.markdown import (
MarkdownNoteFactory,
from personal_mnemonic_medium.data_access.exporters.base import (
CardExporter,
)
from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.prompt_extractors.base import (
from personal_mnemonic_medium.domain.card_pipeline import CardPipeline
from personal_mnemonic_medium.domain.prompt_extractors.base import (
PromptExtractor,
)
from personal_mnemonic_medium.prompt_extractors.cloze_extractor import (
from personal_mnemonic_medium.domain.prompt_extractors.cloze_extractor import (
ClozePromptExtractor,
)
from personal_mnemonic_medium.prompt_extractors.qa_extractor import (
from personal_mnemonic_medium.domain.prompt_extractors.qa_extractor import (
QAPrompt,
QAPromptExtractor,
)
Expand Down Expand Up @@ -91,11 +95,8 @@ def test_get_subtags():


def test_qa_uuid_generation():
file_path = (
Path(__file__).parent.parent.parent
/ "test_md_files"
/ "test_card_guid.md"
)
# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/204 Remove dependency on test_md_files
file_path = Path(__file__).parent / "test_cards.md"
cards = MockCardPipeline(
prompt_extractors=[QAPromptExtractor()]
).run(input_path=file_path)
Expand All @@ -109,11 +110,7 @@ def test_qa_uuid_generation():


def test_cloze_uuid_generation():
file_path = (
Path(__file__).parent.parent.parent
/ "test_md_files"
/ "test_card_guid.md"
)
file_path = Path(__file__).parent / "test_cards.md"
cloze_cards = MockCardPipeline(
prompt_extractors=[ClozePromptExtractor()]
).run(input_path=file_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import textwrap
from typing import Any

from personal_mnemonic_medium.exporters.anki.anki_css import (
from personal_mnemonic_medium.data_access.exporters.anki.anki_css import (
CARD_MODEL_CSS,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@

import genanki

from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.anki.card_types.cloze import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.cloze import (
AnkiCloze,
)
from personal_mnemonic_medium.exporters.anki.card_types.qa import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.qa import (
AnkiQA,
)
from personal_mnemonic_medium.exporters.base import CardExporter
from personal_mnemonic_medium.prompt_extractors.cloze_extractor import (
from personal_mnemonic_medium.data_access.exporters.base import (
CardExporter,
)
from personal_mnemonic_medium.domain.prompt_extractors.cloze_extractor import (
ClozePrompt,
)
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt
from personal_mnemonic_medium.prompt_extractors.qa_extractor import (
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)
from personal_mnemonic_medium.domain.prompt_extractors.qa_extractor import (
QAPrompt,
)
from personal_mnemonic_medium.utils.hasher import simple_hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from genanki import Model, Note
from wasabi import Printer

from personal_mnemonic_medium.exporters.anki.globals import (
from personal_mnemonic_medium.data_access.exporters.anki.globals import (
ANKICONNECT_URL,
)
from personal_mnemonic_medium.exporters.anki.package_generator import (
from personal_mnemonic_medium.data_access.exporters.anki.package_generator import (
DeckBundle,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from pathlib import Path

from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.anki.card_types.qa import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.qa import (
AnkiQA,
)
from personal_mnemonic_medium.exporters.anki.package_generator import (
from personal_mnemonic_medium.data_access.exporters.anki.package_generator import (
AnkiPackageGenerator,
)
from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.prompt_extractors.qa_extractor import (
from personal_mnemonic_medium.domain.prompt_extractors.qa_extractor import (
QAPrompt,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from abc import ABC, abstractmethod
from collections.abc import Sequence

from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)


class CardExporter(ABC):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from collections.abc import Sequence
from pathlib import Path

from personal_mnemonic_medium.exporters.anki.card_types.base import (
from personal_mnemonic_medium.data_access.document_ingesters.base import (
DocumentFactory,
)
from personal_mnemonic_medium.data_access.document_ingesters.document import (
Document,
)
from personal_mnemonic_medium.data_access.exporters.anki.card_types.base import (
AnkiCard,
)
from personal_mnemonic_medium.exporters.base import CardExporter
from personal_mnemonic_medium.note_factories.base import (
DocumentFactory,
from personal_mnemonic_medium.data_access.exporters.base import (
CardExporter,
)
from personal_mnemonic_medium.note_factories.note import Document
from personal_mnemonic_medium.prompt_extractors.base import (
from personal_mnemonic_medium.domain.prompt_extractors.base import (
PromptExtractor,
)
from personal_mnemonic_medium.prompt_extractors.prompt import Prompt
from personal_mnemonic_medium.domain.prompt_extractors.prompt import (
Prompt,
)


class CardPipeline:
Expand Down
Loading

0 comments on commit 5680ad9

Please sign in to comment.