Skip to content

Commit

Permalink
Fixing line length error: Black formatter engines/common/objects (#289)
Browse files Browse the repository at this point in the history
* Formatter engines/common/objects folder

* Fixing line length errors
  • Loading branch information
aviraljain99 committed Jun 17, 2022
1 parent b297ee1 commit 87241ec
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
12 changes: 3 additions & 9 deletions elpis/engines/common/objects/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def __init__(self, basepath: Path):
self.word_count_json: Path = self.basepath.joinpath("word_count.json")
self.word_list_txt: Path = self.basepath.joinpath("word_list.txt")
# \/ user uploaded addional words
self.additional_word_list_txt = self.original.joinpath(
"additional_word_list.txt"
)
self.additional_word_list_txt = self.original.joinpath("additional_word_list.txt")
# \/ compile the uploaded corpora into this single file
self.corpus_txt = self.cleaned.joinpath("corpus.txt")

Expand Down Expand Up @@ -76,9 +74,7 @@ def __init__(self, **kwargs):
def load(cls, base_path: Path):
self = super().load(base_path)
self.pathto = DSPaths(self.path)
self.__files = [
self.pathto.original.joinpath(path) for path in self.config["files"]
]
self.__files = [self.pathto.original.joinpath(path) for path in self.config["files"]]
# at this point config has the previous state
self._importer = self.config["importer"]
temp_state = self._importer
Expand Down Expand Up @@ -391,9 +387,7 @@ def process(self):
additional_corpus_txt=f"{self.pathto.corpus_txt}",
)
# make word count
annotations: List[Dict[str, str]] = load_json_file(
f"{self.pathto.annotation_json}"
)
annotations: List[Dict[str, str]] = load_json_file(f"{self.pathto.annotation_json}")
with self.pathto.word_count_json.open(mode="w") as f_word_count:
wordlist = {}
for transcription in annotations:
Expand Down
4 changes: 1 addition & 3 deletions elpis/engines/common/objects/fsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class FSObject(ABC):
``dir_name`` directory.
"""

_links = (
{}
) # Used for child classes to dynamically link to other objects if applicable.
_links = {} # Used for child classes to dynamically link to other objects if applicable.

# _config_file = '___________.json'
# Do not uncomment line above, this is an example of how to implement the
Expand Down
28 changes: 7 additions & 21 deletions elpis/engines/common/objects/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,20 @@ def new_dataset(self, dsname):

def get_dataset(self, dsname):
if dsname not in self.list_datasets():
raise InterfaceError(
f'Tried to load a dataset called "{dsname}" that does not exist'
)
raise InterfaceError(f'Tried to load a dataset called "{dsname}" that does not exist')
hash_dir = self.config["datasets"][dsname]
return Dataset.load(self.datasets_path.joinpath(hash_dir))

def remove_dataset(self, dsname):
if dsname not in self.list_datasets():
raise InterfaceError(
f'Tried to delete a dataset called "{dsname}" that does not exist'
)
raise InterfaceError(f'Tried to delete a dataset called "{dsname}" that does not exist')
datasets = self.config["datasets"]
del datasets[dsname]
self.config["datasets"] = datasets
for hash_dir in os.listdir(f"{self.datasets_path}"):
if not hash_dir.startswith("."):
names = []
with self.datasets_path.joinpath(
hash_dir, "dataset.json"
).open() as fin:
with self.datasets_path.joinpath(hash_dir, "dataset.json").open() as fin:
names.append(json.load(fin)["name"])
for name in names:
if name == dsname:
Expand All @@ -197,9 +191,7 @@ def new_pron_dict(self, pdname):

def get_pron_dict(self, pdname):
if pdname not in self.list_pron_dicts():
raise InterfaceError(
f'Tried to load a pron dict called "{pdname}" that does not exist'
)
raise InterfaceError(f'Tried to load a pron dict called "{pdname}" that does not exist')
hash_dir = self.config["pron_dicts"][pdname]
pd = PronDict.load(self.pron_dicts_path.joinpath(hash_dir))
pd.dataset = self.get_dataset(pd.config["dataset_name"])
Expand All @@ -216,9 +208,7 @@ def remove_pron_dict(self, pdname):
for hash_dir in os.listdir(f"{self.pron_dicts_path}"):
if not hash_dir.startswith("."):
names = []
with self.pron_dicts_path.joinpath(
hash_dir, "pron_dict.json"
).open() as fin:
with self.pron_dicts_path.joinpath(hash_dir, "pron_dict.json").open() as fin:
names.append(json.load(fin)["name"])
for name in names:
if name == pdname:
Expand Down Expand Up @@ -256,9 +246,7 @@ def get_model(self, mname):
if self.engine is None:
raise RuntimeError("Engine must be set to get a model")
if mname not in self.list_models():
raise InterfaceError(
f'Tried to load a model called "{mname}" that does not exist'
)
raise InterfaceError(f'Tried to load a model called "{mname}" that does not exist')
hash_dir = self.config["models"][mname]
m = self.engine.model.load(self.models_path.joinpath(hash_dir))
m.dataset = self.get_dataset(m.config["dataset_name"])
Expand All @@ -268,9 +256,7 @@ def get_model(self, mname):

def remove_model(self, mname):
if mname not in self.list_models():
raise InterfaceError(
f'Tried to delete a model called "{mname}" that does not exist'
)
raise InterfaceError(f'Tried to delete a model called "{mname}" that does not exist')
models = self.config["models"]
del models[mname]
self.config["models"] = models
Expand Down
4 changes: 1 addition & 3 deletions elpis/engines/common/objects/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def __init__(self, **kwargs):
self.config["stage_status"] = {}
# TODO check if this is used, all the other things here are config settings
self.status = "untrained"
self.config[
"engine_name"
] = None # use this to set engine if loading a model later
self.config["engine_name"] = None # use this to set engine if loading a model later
self.config["results"] = None

@classmethod
Expand Down
4 changes: 1 addition & 3 deletions elpis/engines/common/objects/pron_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def __init__(self, **kwargs):
"dataset"
] = None # dataset hash has not been linked # TODO: change 'dataset' to 'dataset_name'
self.l2s_path = self.path.joinpath("l2s.txt")
self.lexicon_txt_path = self.path.joinpath(
"lexicon.txt"
) # TODO change to lexicon_txt_path
self.lexicon_txt_path = self.path.joinpath("lexicon.txt") # TODO change to lexicon_txt_path
self.config["l2s"] = False # file has not been uploaded
self.config["lexicon"] = False # file has not been generated

Expand Down

0 comments on commit 87241ec

Please sign in to comment.