[draft] Collecting documentation for app runner#220
Draft
leoschwarz wants to merge 9 commits intomainfrom
Draft
Conversation
Member
Author
|
new deploy snippet |
Member
Author
|
Snippet for core Finding EntitiesThe module provides several methods for retrieving entities: # Find a single entity
project = Project.find(id=123, client=client)
# Find multiple entities efficiently
project_ids = [123, 456, 789]
projects = Project.find_all(ids=project_ids, client=client)
# Find entities matching a query
matching_projects = Project.find_by({"name": "My Project"}, client=client)When working with multiple entities, always prefer Working with RelationshipsEntities can have relationships with other entities, defined using # One-to-one relationship
sample = Sample.find(id=123, client=client)
project = sample.project # Automatically loads the related project
# One-to-many relationship
project = Project.find(id=456, client=client)
for sample in project.samples: # Automatically loads all related samples
print(sample.id)
# Access just the IDs without loading entities
sample_ids = project.samples.ids
# Convert to a list or DataFrame
samples_list = project.samples.list
samples_df = project.samples.polarsPerformance TipsFor optimal performance:
Developer GuideThis section is for developers who want to extend or modify the Module StructureThe module consists of several components:
Creating a New Entity TypeTo create a new entity type: from bfabric.entities.core.entity import Entity
from bfabric.entities.core.has_one import HasOne
from bfabric.entities.core.has_many import HasMany
class MyEntity(Entity):
ENDPOINT = "MyEntityEndpoint" # B-Fabric endpoint name
# Define relationships
parent = HasOne("ParentEntity", bfabric_field="parent")
children = HasMany("ChildEntity", bfabric_field="children")
# Add custom methods if needed
def custom_method(self):
return f"Custom functionality for {self.id}"Design PrinciplesWhen extending the module, follow these principles:
Entity Lookup CacheThe from bfabric.experimental.entity_lookup_cache import EntityLookupCache
# Singleton instance
cache = EntityLookupCache.instance()
# Cache operations
cache.put(entity_type=MyEntity, entity_id=123, entity=my_entity)
cached_entity = cache.get(entity_type=MyEntity, entity_id=123)API ReferenceKey Features
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.