function get_all_lims_importerrors
Queries a Neo4j graph database to retrieve all nodes labeled as LIMS_ImportErrors, with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
22 - 29
simple
Purpose
This function is designed to fetch error records from a Laboratory Information Management System (LIMS) that have been imported into a Neo4j graph database. It's useful for debugging, monitoring import failures, or analyzing error patterns in LIMS data integration processes. The function provides a simple interface to retrieve error nodes without requiring direct Cypher query knowledge.
Source Code
def get_all_lims_importerrors(limit=100):
"""Return LIMS_ImportErrors nodes (limited to 25)"""
query = """
MATCH (n:LIMS_ImportErrors)
RETURN n
LIMIT $limit
"""
return run_query(query, {"limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
limit |
- | 100 | positional_or_keyword |
Parameter Details
limit: Maximum number of LIMS_ImportErrors nodes to return. Defaults to 100. Note: The docstring incorrectly states the limit is 25, but the actual default is 100. Accepts any positive integer value to control result set size and prevent overwhelming queries on large datasets.
Return Value
Returns the result of run_query() function, which typically returns a list of Neo4j Record objects or dictionaries containing the LIMS_ImportErrors nodes. Each record contains the properties of a single error node. The exact return type depends on the implementation of run_query(), but commonly returns a list of dictionaries with node properties or Neo4j Result objects. Returns an empty list if no matching nodes are found.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example 1: Get default 100 error records
errors = get_all_lims_importerrors()
for error in errors:
print(error['n'])
# Example 2: Get only 10 error records
errors_limited = get_all_lims_importerrors(limit=10)
# Example 3: Get all available errors (use with caution)
errors_all = get_all_lims_importerrors(limit=10000)
Best Practices
- Be cautious with the limit parameter - setting it too high on large datasets may cause performance issues or memory problems
- The docstring contains incorrect information (states limit of 25 but default is 100) - this should be corrected in production code
- Ensure the run_query() function properly handles database connection errors and returns consistent data structures
- Consider adding error handling for database connection failures
- For production use, consider adding pagination support instead of relying solely on LIMIT
- Validate that the limit parameter is a positive integer before passing to the query
- Consider adding additional filtering parameters (e.g., date range, error type) for more targeted queries
- Ensure proper database connection cleanup is handled by the run_query() function
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_lims_importerrors_by_id 87.1% similar
-
function create_lims_importerrors 81.2% similar
-
function get_all_lims_requests 80.9% similar
-
function get_lims_importerrors_by_uid 80.8% similar
-
function get_all_lims_parameters 80.3% similar