Skip to content

Commit

Permalink
Merge pull request #835 from readthedocs/embedding-fixes
Browse files Browse the repository at this point in the history
A couple small bug fixes for embeddings work
  • Loading branch information
ericholscher committed Feb 22, 2024
2 parents cbbd674 + 6b9fd08 commit 6aeb961
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions adserver/analyzer/management/commands/runmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Command(BaseCommand):

"""Run the ML model on the specified URLs."""

help = "Run the ML model on the specified URLs. Results are not stored to the database."
Expand Down Expand Up @@ -39,13 +38,17 @@ def handle_url(self, url):
keywords = []
embeddings = []
for backend in get_url_analyzer_backends():

backend_instance = backend(url)
response = backend_instance.fetch()
if not response:
continue

analyzed_keywords = backend_instance.analyze(response)
self.stdout.write(
_("Keywords from '%s': %s") % (backend.__name__, analyzed_keywords)
)
analyzed_embedding = backend.embedding(response)
analyzed_embedding = backend_instance.embedding(response)
self.stdout.write(
_("Embeddings from '%s': %s") % (backend.__name__, analyzed_embedding)
)
Expand Down
5 changes: 4 additions & 1 deletion adserver/analyzer/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def analyze_url(url, publisher_slug, force=False):
log.debug("Keywords from '%s': %s", backend.__name__, analyzed_keywords)

analyzed_embedding = backend_instance.embedding(response) # Can be None
log.debug("Embedding from '%s': %s", backend.__name__, len(analyzed_embedding))
if analyzed_embedding:
log.debug(
"Embedding from '%s': %s", backend.__name__, len(analyzed_embedding)
)

if analyzed_keywords:
for kw in analyzed_keywords:
Expand Down

0 comments on commit 6aeb961

Please sign in to comment.