-
Notifications
You must be signed in to change notification settings - Fork 0
added some better retreival on the job manager #430
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
base: main
Are you sure you want to change the base?
Conversation
PR Review: Fix Definition Retrieval (RAPID-6629)Thanks for working on this improvement! I've reviewed the changes and have several observations about code quality, potential issues, and testing considerations. Critical Issues1. Duplicate Import (Line 708)Location: from rapidata.rapidata_client.job.rapidata_job import RapidataJob
from rapidata.rapidata_client.job.rapidata_job import RapidataJobThe Code Quality Issues2. Missing Docstrings for New Public MethodsLocation: The new public methods
Recommendation: def find_jobs(self, name: str = "", amount: int = 10) -> list[RapidataJob]:
"""Find jobs (not definitions) given criteria.
Args:
name (str, optional): The name of the job - matching jobs will contain this name. Defaults to "" for any job.
amount (int, optional): The maximum number of jobs to return. Defaults to 10.
Returns:
list[RapidataJob]: A list of RapidataJob instances.
"""3. Removed Method Without Deprecation WarningLocation: Lines 688-695 (old The private method
Correctness & Best Practices4. API Endpoint ChangeLocation: The change from: job_definition_definition_id_revision_revision_number_get(
definition_id=job_definition_id,
revision_number=1,
)To: job_definition_definition_id_revision_get(
definition_id=job_definition_id,
)This looks correct and is an improvement - it fetches the latest revision automatically instead of hardcoding Positive: The new approach removes hardcoded values and correctly retrieves the latest revision. 5. Debug Logging AddedLocation: logger.debug(f"Latest revision: {latest_revision}")This debug log is helpful for troubleshooting. Consider whether you want to log the entire object or specific fields (like Recommendation: logger.debug(f"Retrieved latest revision for definition {job_definition_id}: revision {latest_revision.revision_number if hasattr(latest_revision, 'revision_number') else 'unknown'}")6. Consistent ID Field AccessLocation: The change from Potential Bugs7. Error HandlingLocation: All three methods None of the new/modified methods have explicit error handling for API failures. Consider what happens if:
Recommendation: Add try-catch blocks with meaningful error messages, similar to patterns used elsewhere in the codebase. 8. Naming InconsistencyLocation: The tracer span name is Fix: with tracer.start_as_current_span("JobManager.find_jobs"):Performance Considerations9. Import PlacementLocation: Lines 700-708 All the imports inside Assessment: This is acceptable if it's a deliberate choice for the codebase, but be aware it adds a small overhead on each function call. Security Concerns10. Input ValidationLocation: All new/modified methods The
Recommendation: Add input validation similar to what's done in other methods: if amount < 1 or amount > 1000: # or whatever your max is
raise ValueError("amount must be between 1 and 1000")Test Coverage11. Missing TestsI couldn't locate test files for the
Recommendation: Add tests covering:
SummaryMust Fix:
Should Fix:
Nice to Have:
The core logic improvement (using the correct API endpoint to fetch the latest revision) is solid and addresses the apparent issue with the old implementation. Once the above issues are addressed, this will be a good improvement to the codebase. |
No description provided.