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
from burr.integrations.ray import RayExecutor | |
persister = SQLitePersister(db_path="./db") | |
persister.initialize() | |
app = ( | |
ApplicationBuilder() | |
.with_actions(user_input, final_results, generate_all_poems=GenerateAllPoems()) | |
.with_transitions( | |
("user_input", "generate_all_poems"), | |
("generate_all_poems", "final_results"), |
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
persister = SQLitePersister(db_path="./db") | |
persister.initialize() | |
app = ( | |
ApplicationBuilder() | |
.with_actions(user_input, final_results, generate_all_poems=GenerateAllPoems()) | |
.with_transitions( | |
("user_input", "generate_all_poems"), | |
("generate_all_poems", "final_results"), | |
) | |
.with_tracker(project="demo:parallel_agents_fault_tolerance") |
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
app = ( | |
ApplicationBuilder() | |
.with_actions(user_input, final_results, generate_all_poems=GenerateAllPoems()) | |
.with_transitions( | |
("user_input", "generate_all_poems"), | |
("generate_all_poems", "final_results"), | |
) | |
.with_tracker(project="demo:parallel_agents") | |
.with_entrypoint("user_input") | |
.build() |
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
class GenerateAllPoems(MapStates): | |
def states( | |
self, state: State, context: ApplicationContext, inputs: Dict[str, Any] | |
) -> SyncOrAsyncGenerator[State]: | |
for poem_type in state["poem_types"]: | |
yield state.update(current_draft=None, poem_type=poem_type, feedback=None) | |
def action(self, state: State, inputs: Dict[str, Any]) -> SubgraphType: | |
graph = ( | |
GraphBuilder() |
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
from datetime import datetime | |
from hamilton.function_modifiers import config, extract_fields, pipe_output, step | |
def _convert_US_to_datatime(date: str) -> datetime: | |
return datetime.strptime(date, "%m/%d/%Y") | |
def _convert_EMEA_to_datatime(date: str) -> datetime: | |
return datetime.strptime(date, "%d/%m/%Y") | |
@pipe_output(step(_convert_EMEA_to_datatime)) |
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
from hamilton.function_modifiers import tag | |
@tag(team="Research") | |
def foo()->int: | |
return 10 | |
@tag(team="Platform") | |
def bar()->int: | |
return 100 |
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
from datetime import datetime | |
from hamilton.function_modifiers import extract_fields | |
def _fetch_dates__EMEA() -> dict: | |
return { | |
"a": "31/01/2000", | |
"b": "28/02/2010", | |
"c": "30/03/2020", | |
} |
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
from datetime import datetime | |
def _fetch_dates__EMEA() -> dict: | |
return { | |
"a": "31/01/2000", | |
"b": "28/02/2010", | |
"c": "30/03/2020", | |
} | |
def _fetch_dates__US() -> dict: |
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
from datetime import datetime | |
def fetch_dates__EMEA() -> dict: | |
return { | |
"a": "31/1/2000", | |
"b": "28/2/2010", | |
"c": "30/3/2020", | |
} | |
def fetch_dates__US() -> dict: |
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
action, _, state = app.run( | |
halt_after=["format_results"], | |
inputs={"query": "What's the weather like in San Francisco?"}, | |
) | |
print(state["final_output"]) |