TrainingBankAccountMgmt
Versions
v1.0.0
Basic Information
Class Name: TrainingBankAccountMgmt
Title: Training - Bank Account Mgmt
Version: 1.0.0
Author: Drew Shea
Organization: OneStream
Creation Date: 2025-05-26
Default Routine Memory Capacity: 2 GB
Tags
Learning Guide
Description
Short Description
A simple Stateful Routine to demonstrate how Routines work through a bank account management use case.
Long Description
This Routine is designed to demonstrate how to create a simple Stateful Routine that allows users to create a bank account, deposit money, withdraw money, and get an account summary. It is part of a training series for individuals to learn how to build as well as interact with Routines and their inputs/outputs.The Routine is designed to be simple and easy to understand, while also demonstrating the key features of Routines, such as member variables, method execution, and artifact generation. It also demonstrates how to use the RoutineApi to update the status of the run, log messages, and handle errors. Lastly, it also include in-memory execution for quick operations that do not require heavy computation.
Use Cases
1. Training New Routine Power Users
A Routine Power User is a consultant, developer, or OneStream Power User that wants to run and interact with Routines to powersome business process. This example Routine is designed to be simple and easy to understand so that a Routine Power User can get comfortable with a Stateful Routine. A Routine Power User can use this Routine to understand what it means to: 1) Interact (either programmatically or through the UI) 2) Create a Routine Instance that takes parameters and maintains internal state. 3) Invoke Routine Methods on the Routine Instance to perform actions. 4) Visualize the Artifacts generated by running a Routine Method. 5) Programmatically interact with Routine Artifacts. 6) Leverage the advanced In-Memory Execution capabilities of certain Routine Methods (ex: deposit, get_account_summary) to run them at the web-server level without needing to be run on a worker so that they may be run at the UI layer (and not require a background task to run).
2. Training New Routine Developers
A Routine Developer is a developer that wants to create Routines in Python that then Routine Power User's can use. Note: The ability to create Routines is not exposed outside of the OneStream organization, so this is only for internal developers that want to create Routines for their own use or for other Routine Power Users. At a later date, we will expose the ability to create Routines to external developers, but for now, this is only for internal developers. This example Routine is designed to be simple and easy to understand so that a Routine Developer can get comfortable with what a Stateful Routine is, how to create one, and how to implement the methods that a Routine Power User can invoke. A Routine Developer can use this Routine to understand what it means to: 1) Create a Stateful Routine that maintains internal state using member variables. 2) Implement Routine Methods that can be invoked by Routine Power Users. 3) Use the RoutineApi to update the status of the run, log messages, and handle errors. 4) Generate Artifacts that can be visualized by Routine Power Users. 5) Expose certain Routine Methods to allow in-memory execution, meaning they can be run at the web-server level. 6) Use the RoutineApi to access the Routine Instance and its member variables.7) Build Routine Method inputs as ParameterBaseModels with multiple states, dynamic options, and validation.
Routine Methods
1. Init (Constructor)
- Method:
__init__-
Type: Constructor
-
Memory Capacity: 2.0 GB
-
Allow In-Memory Execution: No
-
Read Only: No
-
Method Limits: N/A
-
Outputs Dynamic Artifacts: No
-
Short Description:
- The constructor for creating a new bank account at "Bank Of Routine".
-
Detailed Description:
- This method initializes the bank account with the provided parameters, such as the account holder's name, income, initial deposit, and account type. Note, the constructor itself ALWAYS takes a RoutineApi and the parameters for the constructor.
-
Inputs:
- Required Input
- Name: The name of the individual acquiring this bank account.
- Name:
name - Tooltip:
- Detail:
- This should be the individual's full name (including middle name). This will be used to identify the account holder.
- Validation Constraints:
- The input must have a minimum length of 1.
- The input must have a maximum length of 100.
- This input may be subject to other validation constraints at runtime.
- Detail:
- Type: str
- Name:
- Date of Birth: The date of birth of the individual acquiring this bank account.
- Name:
date_of_birth - Tooltip:
- Validation Constraints:
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: datetime
- Name:
- Yearly Income: The yearly income of the individual acquiring this bank account.
- Name:
income - Tooltip:
- Validation Constraints:
- The input must be greater than 0.0.
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: float
- Name:
- Account Type: The type of bank account to be created.
- Name:
account_type - Tooltip:
- Validation Constraints:
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: str
- Name:
- Initial Deposit: An initial deposit amount to be made into the account.
- Name:
initial_deposit - Tooltip:
- Detail:
- Note that if you put more than 10,000, the bank will give you a 500 dollar opening account bonus. But only if you ask!
- Validation Constraints:
- The input must be greater than or equal to 1000.
- This input may be subject to other validation constraints at runtime.
- Detail:
- Type: float
- Name:
- Name: The name of the individual acquiring this bank account.
- Optional Input
- Gender: The gender of the individual acquiring this bank account.
- Name:
gender - Tooltip:
- Validation Constraints:
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: Optional[Literal]
- Name:
- Gender: The gender of the individual acquiring this bank account.
- Required Input
-
Artifacts: No artifacts are returned by this method
-
2. Deposit (Method)
- Method:
deposit-
Type: Method
-
Memory Capacity: 2.0 GB
-
Allow In-Memory Execution: Yes
-
Read Only: No
-
Method Limits: N/A
-
Outputs Dynamic Artifacts: No
-
Short Description:
- Deposit money into the bank account.
-
Detailed Description:
- Notice how this does not return anything, but rather updates the state of the routine. Additionally, also note that it allows in-memory execution, meaning it can be run at the web-server level without needing to be run on a worker. This is useful for quick operations that do not require heavy computation.
-
Inputs:
- Required Input
- Deposit Amount: The amount of money to deposit into the bank account.
- Name:
amount - Tooltip:
- Validation Constraints:
- The input must be greater than 0.0.
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: float
- Name:
- Deposit Amount: The amount of money to deposit into the bank account.
- Required Input
-
Artifacts: No artifacts are returned by this method
-
3. Get Account Summary (Method)
- Method:
get_account_summary-
Type: Method
-
Memory Capacity: 2.0 GB
-
Allow In-Memory Execution: Yes
-
Read Only: No
-
Method Limits: N/A
-
Outputs Dynamic Artifacts: No
-
Short Description:
- Get the current balance of the account holder.
-
Detailed Description:
- This method retrieves the account summary, including the account creation date, account holder's name, current balance. Additionally, also note that it allows in-memory execution, meaning it can be run at the web-server level without needing to be run on a worker. This is useful for quick operations that do not require heavy computation.
-
Inputs:
- No input parameters
-
Artifacts:
-
Request Receipt: A system generated request receipt indicating that this information was requested by the account holder.
- Qualified Key Annotation:
request_receipt - Aggregate Artifact:
False - In-Memory Json Accessible:
True - File Annotations:
artifacts_/@request_receipt/data_/string.txt- A text file of string data.
- Qualified Key Annotation:
-
Account Summary: A json payload containing the account summary information.
- Qualified Key Annotation:
account_summary - Aggregate Artifact:
False - In-Memory Json Accessible:
True - File Annotations:
artifacts_/@account_summary/data_/data.json- Stored json data.
artifacts_/@account_summary/data_/schema.json- The json schema of the json object stored in the 'data.json' file
- Qualified Key Annotation:
-
-
4. Withdraw (Method)
- Method:
withdraw-
Type: Method
-
Memory Capacity: 2.0 GB
-
Allow In-Memory Execution: No
-
Read Only: No
-
Method Limits: N/A
-
Outputs Dynamic Artifacts: No
-
Short Description:
- Withdraw money from the bank account.
-
Detailed Description:
- This method checks if the withdrawal amount is less than or equal to the current balance. If it is, it proceeds with the withdrawal, updates the balance, and returns an artifact containing the amount withdrawn. If the withdrawal amount exceeds the current balance, it raises a ValueError indicating insufficient funds.
-
Inputs:
- Required Input
- Withdrawal Amount: The amount of money to withdraw from the bank account.
- Name:
amount - Tooltip:
- Validation Constraints:
- The input must be greater than 0.0.
- This input may be subject to other validation constraints at runtime.
- Validation Constraints:
- Type: float
- Name:
- Withdrawal Amount: The amount of money to withdraw from the bank account.
- Required Input
-
Artifacts:
- Dollars: A system generated receipt indicating the amount of dollars withdrawn from the account.
- Qualified Key Annotation:
dollars - Aggregate Artifact:
False - In-Memory Json Accessible:
True - File Annotations:
artifacts_/@dollars/data_/float.txt- A text file holding float number.
- Qualified Key Annotation:
- Dollars: A system generated receipt indicating the amount of dollars withdrawn from the account.
-
Interface Definitions
No interface definitions found for this routine
Developer Docs
Routine Typename: TrainingBankAccountMgmt
| Method Name | Artifact Keys |
|---|---|
__init__ | N/A |
deposit | N/A |
get_account_summary | request_receipt, account_summary |
withdraw | dollars |