-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardize callables #1275
Standardize callables #1275
Conversation
1f9357f
to
1e9338b
Compare
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
673d0f4
to
2c16ced
Compare
what is the reasoning between |
Reposted my comment linked in the description.
Multiple calls to a factory should give new objects with new meaning each time. For instance, 3 calls to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Like the renames.
Just optional suggestions. Don't necessarily need to be done in this PR either.
@@ -15,24 +15,26 @@ | |||
|
|||
@define | |||
class SnowflakeSqlDriver(BaseSqlDriver): | |||
connection_func: Callable[[], SnowflakeConnection] = field(kw_only=True) | |||
connection_provider: Callable[[], SnowflakeConnection] = field(kw_only=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to create some reusable types for these to make it easier for customer code create their own abstractions.
For example adding a:
ConnectionProvider = Callable[[], SnowflakeConnection]
In this file, then using it here:
connection_provider: ConnectionProvider = field(kw_only=True)
And you can reduce duplicate in def validate_connection_provider(
too.
I can also see arguments against this, but I like being able to easily references types in my own code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I like the idea, but that can be introduced in the future.
relatedness_fn: Callable = field(default=lambda x, y: dot(x, y) / (norm(x) * norm(y))) | ||
relatedness_calculator: Callable = field(default=lambda x, y: dot(x, y) / (norm(x) * norm(y))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no generic params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should be there but I want to keep this PR strictly on naming.
@@ -7,7 +7,7 @@ class TestTextSummaryTask: | |||
@pytest.fixture( | |||
autouse=True, | |||
params=StructureTester.TEXT_SUMMARY_TASK_CAPABLE_PROMPT_DRIVERS, | |||
ids=StructureTester.prompt_driver_id_fn, | |||
ids=StructureTester.generate_prompt_driver_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this prompt_driver_id_provider
or prompt_driver_id_factory
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that's actually a class method, not a field. Methods should still be verb-noun.
2c16ced
to
5aae5bd
Compare
c2170a0
to
c0d713f
Compare
e3ab6d2
to
eae2222
Compare
eae2222
to
26768e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets update the PR description for posterity
Describe your changes
Relevant thread
Changed
LocalStructureRunDriver.structure_factory_fn
toLocalStructureRunDriver.create_structure
.SnowflakeSqlDriver.connection_func
toSnowflakeSqlDriver.get_connection
.CsvLoader.formatter_fn
toCsvLoader.format_row
.SqlLoader.formatter_fn
toSqlLoader.format_row
.CsvExtractionEngine.system_template_generator
toCsvExtractionEngine.generate_system_template
.CsvExtractionEngine.user_template_generator
toCsvExtractionEngine.generate_user_template
.JsonExtractionEngine.system_template_generator
toJsonExtractionEngine.generate_system_template
.JsonExtractionEngine.user_template_generator
toJsonExtractionEngine.generate_user_template
.PromptResponseRagModule.generate_system_template
toPromptResponseRagModule.generate_system_template
.PromptTask.generate_system_template
toPromptTask.generate_system_template
.ToolkitTask.generate_assistant_subtask_template
toToolkitTask.generate_assistant_subtask_template
.JsonSchemaRule.template_generator
toJsonSchemaRule.generate_template
.ToolkitTask.generate_user_subtask_template
toToolkitTask.generate_user_subtask_template
.TextLoaderRetrievalRagModule.process_query_output_fn
toTextLoaderRetrievalRagModule.process_query_output
.FuturesExecutorMixin.futures_executor_fn
toFuturesExecutorMixin.create_futures_executor
.VectorStoreTool.process_query_output_fn
toVectorStoreTool.process_query_output
.CodeExecutionTask.run_fn
toCodeExecutionTask.on_run
.Chat.input_fn
toChat.handle_input
.Chat.output_fn
toChat.handle_output
.EventListener.handler
toEventListener.on_event
.Issue ticket number and link
Closes #285
📚 Documentation preview 📚: https://griptape--1275.org.readthedocs.build//1275/