[#2] typo in paths
Browse files- idiomify/fetchers.py +5 -4
- idiomify/paths.py +2 -2
idiomify/fetchers.py
CHANGED
@@ -4,12 +4,13 @@ from os import path
|
|
4 |
import pandas as pd
|
5 |
from typing import Tuple, List
|
6 |
from wandb.sdk.wandb_run import Run
|
7 |
-
from idiomify.paths import CONFIG_YAML, idioms_dir, literal2idiomatic,
|
8 |
from idiomify.urls import PIE_URL
|
9 |
from transformers import AutoModelForSeq2SeqLM, AutoConfig
|
10 |
from idiomify.models import Idiomifier
|
11 |
|
12 |
|
|
|
13 |
def fetch_pie() -> pd.DataFrame:
|
14 |
# fetch & parse it directly from the web
|
15 |
return pd.read_csv(PIE_URL)
|
@@ -57,11 +58,11 @@ def fetch_idiomifier(ver: str, run: Run = None) -> Idiomifier:
|
|
57 |
else:
|
58 |
artifact = wandb.Api().artifact(f"eubinecto/idiomify/idiomifier:{ver}", type="model")
|
59 |
config = artifact.metadata
|
60 |
-
artifact_dir = artifact.download(root=
|
61 |
ckpt_path = path.join(artifact_dir, "model.ckpt")
|
62 |
bart = AutoModelForSeq2SeqLM.from_config(AutoConfig.from_pretrained(config['bart']))
|
63 |
-
|
64 |
-
return
|
65 |
|
66 |
|
67 |
def fetch_config() -> dict:
|
|
|
4 |
import pandas as pd
|
5 |
from typing import Tuple, List
|
6 |
from wandb.sdk.wandb_run import Run
|
7 |
+
from idiomify.paths import CONFIG_YAML, idioms_dir, literal2idiomatic, idiomifier_dir
|
8 |
from idiomify.urls import PIE_URL
|
9 |
from transformers import AutoModelForSeq2SeqLM, AutoConfig
|
10 |
from idiomify.models import Idiomifier
|
11 |
|
12 |
|
13 |
+
# --- from the web --- #
|
14 |
def fetch_pie() -> pd.DataFrame:
|
15 |
# fetch & parse it directly from the web
|
16 |
return pd.read_csv(PIE_URL)
|
|
|
58 |
else:
|
59 |
artifact = wandb.Api().artifact(f"eubinecto/idiomify/idiomifier:{ver}", type="model")
|
60 |
config = artifact.metadata
|
61 |
+
artifact_dir = artifact.download(root=idiomifier_dir(ver))
|
62 |
ckpt_path = path.join(artifact_dir, "model.ckpt")
|
63 |
bart = AutoModelForSeq2SeqLM.from_config(AutoConfig.from_pretrained(config['bart']))
|
64 |
+
model = Idiomifier.load_from_checkpoint(ckpt_path, bart=bart)
|
65 |
+
return model
|
66 |
|
67 |
|
68 |
def fetch_config() -> dict:
|
idiomify/paths.py
CHANGED
@@ -13,5 +13,5 @@ def literal2idiomatic(ver: str) -> Path:
|
|
13 |
return ARTIFACTS_DIR / f"literal2idiomatic_{ver}"
|
14 |
|
15 |
|
16 |
-
def
|
17 |
-
return ARTIFACTS_DIR / f"
|
|
|
13 |
return ARTIFACTS_DIR / f"literal2idiomatic_{ver}"
|
14 |
|
15 |
|
16 |
+
def idiomifier_dir(ver: str) -> Path:
|
17 |
+
return ARTIFACTS_DIR / f"idiomifier_{ver}"
|