Comments (2)
Hello @mcvady,
transitions
decorates models with trigger and state check methods as well as a generic trigger
method to process events by name. I am not super familiar with pydantic but it seems like BaseModel does not allow to set attributes that haven't been explicitly defined. One way to deal with this is to allow extra attributes during model initialisation:
from pydantic import BaseModel, ConfigDict
from transitions import Machine
class Matter(BaseModel):
model_config = ConfigDict(extra='allow')
name: str
lump = Matter(name="Mr. Lumpy")
machine = Machine(model=lump)
Maybe there are ways in pedantic to define dynamically added attributes. Maybe it's even possible to define a model and pass it -- like for instance DocMachine -- to transitions for machine configuration. Currently, I would not say that this is a bug but rather the way transitions operates.
from transitions.
Closing this since there has been no feedback for over 2 weeks. Feel free to comment if the issue still persists. I will reopen the issue if necessary.
from transitions.
Related Issues (20)
- Project dependencies may have API risk issues HOT 1
- Dynamically adding HSM to an existing state, results in child transitions to be absent.
- Mermaid diagrams HOT 4
- maximum recursion depth exceeded while calling a Python object HOT 1
- State transition during on_exception callback causes RecursionError
- "on_exception" is not invoked for "KeyboardInterrupt"
- Explicitly reexport package names
- GraphMachine: set proportional font or allow caller control HOT 3
- AttributeError: 'state' does not exist HOT 3
- prepare func raises Exception altough on_exception is defined HOT 1
- GraphMachine seems not working for parallel states HOT 1
- AsyncMachine transitions fail when a list of `State` objects are passed in to the FSM. HOT 2
- get_triggers does not work HOT 3
- All possible transitions are initialized, instead of those provided as an argument. HOT 2
- Machine get into wrong state. HOT 1
- after_state_change not triggered by set_state HOT 2
- AsyncMachine with queued transitions breaks when transition is cancelled
- AsyncMachine transitions aren't atomic HOT 4
- The Event and Machine have cyclic dependency. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transitions.