Skip to content

Commit

Permalink
Reduce Docker memory limit to 2g and implement section processing opt…
Browse files Browse the repository at this point in the history
…imization in ActSectionUpdaterTask
  • Loading branch information
miskibin committed Nov 3, 2024
1 parent 6ffd0c3 commit 9d5f8b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ services:
- C_FORCE_ROOT=true
env_file:
- .env
mem_limit: 4g
mem_limit: 2g
certbot:
image: certbot/dns-cloudflare
volumes:
Expand Down
10 changes: 9 additions & 1 deletion src/eli_app/db_update/update_law.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def fetch_metadata_and_text(self, eli: str):
return metadata, full_text

def process_chapters(self, eli: str, chapters: list[ActSection], metadata: dict):
new_sections_count = 0 # Counter for new sections created

for chapter in chapters:
if self.should_skip_section(eli, chapter):
logger.info(
Expand All @@ -81,9 +83,15 @@ def process_chapters(self, eli: str, chapters: list[ActSection], metadata: dict)
"summary": summary,
},
)
sleep(8)
new_sections_count += 1 # Increment the counter
sleep(5)
logger.info(f"Updated section {chapter.chapters}")

# Run process_sections_without_embeddings every 20 new sections
if new_sections_count >= 20:
self.process_sections_without_embeddings()
new_sections_count = 0 # Reset the counter

def should_skip_section(self, eli: str, chapter: ActSection) -> bool:
existing_section = ActSection.objects.filter(
act=Act.objects.get(ELI=eli),
Expand Down

0 comments on commit 9d5f8b4

Please sign in to comment.