Skip to content

Commit

Permalink
Basic pydantic instances
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchatmangpt committed Feb 23, 2024
1 parent 1ba2b92 commit ed9752c
Show file tree
Hide file tree
Showing 187 changed files with 1,848 additions and 487 deletions.
4 changes: 0 additions & 4 deletions frontend/src/component/Dictaphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const Dictaphone = () => {
const [serverResponse, setServerResponse] = useState(null);
const [pythonCode, setPythonCode] = useState(null); // State for the code editor

if (!browserSupportsSpeechRecognition) {
return <span>Browser does not support speech recognition.</span>;
}

const sendTranscript = async () => {
const response = await fetch("/receive_transcript", {
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry] # https://python-poetry.org/docs/pyproject/
name = "rdddy"
version = "2024.1.23"
version = "2024.2.22"
description = "Reactive DDD framework with DSPy"
authors = ["Sean Chatman <[email protected]>"]
readme = "README.md"
Expand Down
12 changes: 9 additions & 3 deletions src/autospider/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def handle_evaluate_scraping_precondition_query(
):
print(f"Evaluating scraping precondition for URL {message.url}")
# Example: Pretend the precondition is always met
await self.publish(ScrapingPreconditionEvaluatedEvent(url=message.url, result=True))
await self.publish(
ScrapingPreconditionEvaluatedEvent(url=message.url, result=True)
)


class ProcessingActor(AbstractActor):
Expand All @@ -50,7 +52,9 @@ async def handle_execute_scraping_command(self, message: ExecuteScrapingCommand)
async def handle_evaluate_scraping_post_condition_query(
self, message: EvaluateScrapingPostconditionQuery
):
await self.publish(ScrapingPostconditionEvaluatedEvent(url=message.url, result=True))
await self.publish(
ScrapingPostconditionEvaluatedEvent(url=message.url, result=True)
)


class CompletionActor(AbstractActor):
Expand All @@ -65,5 +69,7 @@ async def handle_scraping_postcondition_evaluated_event(
else:
print(f"Postconditions not met for URL {message.url}.")
await self.publish(
ScrapingErrorEvent(url=message.url, error_message="Postcondition failed")
ScrapingErrorEvent(
url=message.url, error_message="Postcondition failed"
)
)
2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_aggregate/book_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class BookAggregate(AbstractAggregate):
"""Generated class for BookAggregate, inheriting from AbstractAggregate."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class CustomerAggregate(AbstractAggregate):
"""Generated class for CustomerAggregate, inheriting from AbstractAggregate."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderAggregate(AbstractAggregate):
"""Generated class for OrderAggregate, inheriting from AbstractAggregate."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderCancellationPolicy(AbstractPolicy):
"""Generated class for OrderCancellationPolicy, inheriting from AbstractPolicy."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_policy/refund_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class RefundPolicy(AbstractPolicy):
"""Generated class for RefundPolicy, inheriting from AbstractPolicy."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_policy/shipping_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class ShippingPolicy(AbstractPolicy):
"""Generated class for ShippingPolicy, inheriting from AbstractPolicy."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class BookCatalogReadModel(AbstractReadModel):
"""Generated class for BookCatalogReadModel, inheriting from AbstractReadModel."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class CustomerOrderHistoryReadModel(AbstractReadModel):
"""Generated class for CustomerOrderHistoryReadModel, inheriting from AbstractReadModel."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderSummaryReadModel(AbstractReadModel):
"""Generated class for OrderSummaryReadModel, inheriting from AbstractReadModel."""

pass

72 changes: 57 additions & 15 deletions src/experiments/actor/abstract_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,82 @@ class {{ classname }}({{ base_class_name }}):
to = "{{ base_class_name | underscore }}/{{ classname | underscore }}.py"



def generate_class_definitions(model: EventStormingDomainSpecificationModel):
for attr, base_class_name in base_class_mapping.items():
classnames = getattr(model, attr, [])
for classname in classnames:
tmpl = GenRDDDYClassTemplate(base_class_name=base_class_name, classname=classname)()
tmpl = GenRDDDYClassTemplate(
base_class_name=base_class_name, classname=classname
)()

# Here, instead of render_str, you render the class_definition directly
# print(class_definition) # Or save to a file as needed


def main():
event_storm_model_data = {
"domain_event_classnames": ["OrderPlaced", "PaymentProcessed", "InventoryUpdated"],
"external_event_classnames": ["ExternalPaymentConfirmation", "SupplierInventoryUpdate", "SupplierInventoryConfirmation"],
"domain_event_classnames": [
"OrderPlaced",
"PaymentProcessed",
"InventoryUpdated",
],
"external_event_classnames": [
"ExternalPaymentConfirmation",
"SupplierInventoryUpdate",
"SupplierInventoryConfirmation",
],
"command_classnames": ["PlaceOrder", "ProcessPayment", "UpdateInventory"],
"query_classnames": ["GetOrderDetails", "ListBooks", "CheckOrderStatus"],
"aggregate_classnames": ["OrderAggregate", "BookAggregate", "CustomerAggregate"],
"policy_classnames": ["OrderCancellationPolicy", "RefundPolicy", "ShippingPolicy"],
"read_model_classnames": ["OrderSummaryReadModel", "BookCatalogReadModel", "CustomerOrderHistoryReadModel"],
"aggregate_classnames": [
"OrderAggregate",
"BookAggregate",
"CustomerAggregate",
],
"policy_classnames": [
"OrderCancellationPolicy",
"RefundPolicy",
"ShippingPolicy",
],
"read_model_classnames": [
"OrderSummaryReadModel",
"BookCatalogReadModel",
"CustomerOrderHistoryReadModel",
],
"view_classnames": ["OrderDetailsView", "BookListView", "CustomerProfileView"],
"ui_event_classnames": ["AddToCartButtonClick", "CheckoutFormSubmitted", "OrderHistoryPageLoaded"],
"saga_classnames": ["OrderFulfillmentSaga", "PaymentProcessingSaga", "BookRestockSaga"],
"integration_event_classnames": ["OrderPlacedIntegrationEvent", "PaymentProcessedIntegrationEvent",
"InventoryUpdatedIntegrationEvent"],
"exception_classnames": ["OrderNotFoundException", "PaymentDeclinedException", "BookOutOfStockException"],
"ui_event_classnames": [
"AddToCartButtonClick",
"CheckoutFormSubmitted",
"OrderHistoryPageLoaded",
],
"saga_classnames": [
"OrderFulfillmentSaga",
"PaymentProcessingSaga",
"BookRestockSaga",
],
"integration_event_classnames": [
"OrderPlacedIntegrationEvent",
"PaymentProcessedIntegrationEvent",
"InventoryUpdatedIntegrationEvent",
],
"exception_classnames": [
"OrderNotFoundException",
"PaymentDeclinedException",
"BookOutOfStockException",
],
"value_object_classnames": ["Address", "Price", "Quantity"],
"task_classnames": ["ValidateOrder", "CalculateShippingCosts", "SendOrderConfirmationEmail"],
"task_classnames": [
"ValidateOrder",
"CalculateShippingCosts",
"SendOrderConfirmationEmail",
],
}

event_storm_model = EventStormingDomainSpecificationModel.model_validate(event_storm_model_data)
event_storm_model = EventStormingDomainSpecificationModel.model_validate(
event_storm_model_data
)

generate_class_definitions(event_storm_model)


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_saga/book_restock_saga.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class BookRestockSaga(AbstractSaga):
"""Generated class for BookRestockSaga, inheriting from AbstractSaga."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderFulfillmentSaga(AbstractSaga):
"""Generated class for OrderFulfillmentSaga, inheriting from AbstractSaga."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class PaymentProcessingSaga(AbstractSaga):
"""Generated class for PaymentProcessingSaga, inheriting from AbstractSaga."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class CalculateShippingCosts(AbstractTask):
"""Generated class for CalculateShippingCosts, inheriting from AbstractTask."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class SendOrderConfirmationEmail(AbstractTask):
"""Generated class for SendOrderConfirmationEmail, inheriting from AbstractTask."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_task/validate_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class ValidateOrder(AbstractTask):
"""Generated class for ValidateOrder, inheriting from AbstractTask."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_value_object/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Address(AbstractValueObject):
"""Generated class for Address, inheriting from AbstractValueObject."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_value_object/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Price(AbstractValueObject):
"""Generated class for Price, inheriting from AbstractValueObject."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_value_object/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Quantity(AbstractValueObject):
"""Generated class for Quantity, inheriting from AbstractValueObject."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_view/book_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class BookListView(AbstractView):
"""Generated class for BookListView, inheriting from AbstractView."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class CustomerProfileView(AbstractView):
"""Generated class for CustomerProfileView, inheriting from AbstractView."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/abstract_view/order_details_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderDetailsView(AbstractView):
"""Generated class for OrderDetailsView, inheriting from AbstractView."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/command/place_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class PlaceOrder(Command):
"""Generated class for PlaceOrder, inheriting from Command."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/command/process_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class ProcessPayment(Command):
"""Generated class for ProcessPayment, inheriting from Command."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/command/update_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class UpdateInventory(Command):
"""Generated class for UpdateInventory, inheriting from Command."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class BookOutOfStockException(DomainException):
"""Generated class for BookOutOfStockException, inheriting from DomainException."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OrderNotFoundException(DomainException):
"""Generated class for OrderNotFoundException, inheriting from DomainException."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class PaymentDeclinedException(DomainException):
"""Generated class for PaymentDeclinedException, inheriting from DomainException."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/event/add_to_cart_button_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class AddToCartButtonClick(Event):
"""Generated class for AddToCartButtonClick, inheriting from Event."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/event/checkout_form_submitted.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class CheckoutFormSubmitted(Event):
"""Generated class for CheckoutFormSubmitted, inheriting from Event."""

pass

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class ExternalPaymentConfirmation(AbstractEvent):
"""Generated class for ExternalPaymentConfirmation, inheriting from Event."""

pass

2 changes: 1 addition & 1 deletion src/experiments/actor/event/inventory_updated.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class InventoryUpdated(Event):
"""Generated class for InventoryUpdated, inheriting from Event."""

pass

Loading

0 comments on commit ed9752c

Please sign in to comment.