Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRETTY UP Gloss property idgloss #1352

Open
susanodd opened this issue Oct 23, 2024 · 0 comments
Open

PRETTY UP Gloss property idgloss #1352

susanodd opened this issue Oct 23, 2024 · 0 comments

Comments

@susanodd
Copy link
Collaborator

susanodd commented Oct 23, 2024

This code (see code fragment below) is referenced for making the 2-char sub-folders for the dataset videos/images. It's old as can be seen by the omission of explicit exceptions raised. There are/is also an extreme number of try-except clauses. It's also linked to file permission errors if the file system can't create a folder for first two characters of the result returned here.

[MOTIVATION]
This issue is labelled as a BUG because there are "silent" errors going on here. (There are exceptions but those are actually unexpected and actually model/data errors that are not being raised, a gloss that is missing a lemma? a gloss that is not in a dataset? Something probably went wrong during gloss creation.... The gloss is messed up!)

[RELATED BUGS]
This is also related to bugs on the development servers if the "video files" and "subfolders" have never been created on the development servers (where we TEST CODE) raise permission errors, or do not exist. The "paths" exist inside the GlossVideo objects, but actually do not "physically" exist on the servers. This makes it impossible to effectively test the code during development.

[CREATE MOCK FILE SYSTEM ON DEVELOPMENT SERVERS]
Perhaps all the "folder structures" that "exist on the production server" could be created somehow to duplicate it. But put empty video stubs where real videos exist. (To make it possible to actually test the code during development.)

[REALLY UGLY CODE]

@property
def idgloss(self):
if not self.lemma:
return str(self.id)
if not self.lemma.dataset:
return str(self.id)
try:
return self.lemma.lemmaidglosstranslation_set.get(language=self.lemma.dataset.default_language).text
except:
pass
try:
return self.lemma.lemmaidglosstranslation_set.get(
language__language_code_2char=settings.DEFAULT_KEYWORDS_LANGUAGE['language_code_2char']).text
except:
pass
try:
return self.lemma.lemmaidglosstranslation_set.first().text
except:
return str(self.id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants