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

feat: Update growth stage and growth stage start date in FarmRegistry #407

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

osundwajeff
Copy link
Contributor

Fix #370

Copy link

github-actions bot commented Jan 28, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
16392 15435 94% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: b98838a by action🐍

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 93.50649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 94.04%. Comparing base (dad4f7e) to head (b98838a).

Files with missing lines Patch % Lines
django_project/dcas/pipeline.py 85.71% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #407      +/-   ##
==========================================
- Coverage   94.04%   94.04%   -0.01%     
==========================================
  Files         259      259              
  Lines       15841    15910      +69     
==========================================
+ Hits        14898    14962      +64     
- Misses        943      948       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@osundwajeff osundwajeff marked this pull request as ready for review January 29, 2025 08:17
def update_farm_registry_growth_stage(self):
"""Efficiently update growth stage in FarmRegistry."""
# Load Data
grid_crop_df = self.data_query.read_grid_data_crop_meta_parquet(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osundwajeff this should be query to the farm parquet files like you did on error handling. It needs to accept year, month, and day from the DCASRequest.requested_at.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to use chunks to avoid loading all data in the memory.

# Find Existing FarmRegistry Records
farm_ids = list(farm_mapping.values()) # Get farm IDs
existing_farm_registry = {
fr.farm_id: fr for fr in FarmRegistry.objects.filter(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use 'registry_id' column from the parquet to filter by 'id__in'.

@@ -470,6 +541,7 @@ def run(self):
self.process_grid_crop_data()

self.process_farm_registry_data()
self.update_farm_registry_growth_stage()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please call this method to celery task with input of request_id from DCASRequest

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

Successfully merging this pull request may close these issues.

Update FarmRegistry last growth stage and its start date
2 participants