-
Notifications
You must be signed in to change notification settings - Fork 8
Model api #27
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
Merged
Merged
Model api #27
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
730a8e3
WIP
ezvz dc59ae6
WIP
ezvz c1c581a
WIP
ezvz 846bce5
Convert map to TDataType
chewys1024 9902238
Changed output schema to just a TDataType
chewys1024 e610abd
Merge branch 'main' of https://github.com/zipline-ai/chronon into mod…
chewys1024 73c4fd8
Fix lint issues.
chewys1024 03357f1
Merge branch 'main' of https://github.com/zipline-ai/chronon into mod…
chewys1024 2327459
Make modelParams optional as per coderabbit suggestion
chewys1024 459da08
Maintain default value of empty dict for modelParams in the resulting…
chewys1024 12c24ff
Fix pylint error
chewys1024 b8d7792
Accept DataKind as outputSchema and convert DataKind outputSchema to …
chewys1024 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import ai.chronon.api.ttypes as ttypes | ||
| from typing import Optional | ||
|
|
||
|
|
||
| class ModelType: | ||
| XGBoost = ttypes.ModelType.XGBoost | ||
| PyTorch = ttypes.ModelType.PyTorch | ||
|
|
||
|
|
||
| # Name must match S3 path that we expose if you're uploading trained models? | ||
| def Model( | ||
| source: ttypes.Source, | ||
| outputSchema: ttypes.TDataType, | ||
| modelType: ModelType, | ||
| name: str = None, | ||
| modelParams: Optional[dict[str, str]] = None | ||
| ) -> ttypes.Model: | ||
| if not isinstance(source, ttypes.Source): | ||
| raise ValueError("Invalid source type") | ||
| if not (isinstance(outputSchema, ttypes.TDataType) or isinstance(outputSchema, int)): | ||
| raise ValueError("outputSchema must be a TDataType or DataKind") | ||
| if isinstance(outputSchema, int): | ||
| # Convert DataKind to TDataType | ||
| outputSchema = ttypes.TDataType(outputSchema) | ||
|
|
||
| if modelParams is None: | ||
| modelParams = {} | ||
|
|
||
| metaData = ttypes.MetaData( | ||
| name=name, | ||
| ) | ||
|
|
||
| return ttypes.Model(modelType=modelType, outputSchema=outputSchema, source=source, | ||
chewy-zlai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| modelParams=modelParams, metaData=metaData) | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| from ai.chronon.model import Model, ModelType | ||
| from ai.chronon.api.ttypes import DataKind, EventSource, Source, TDataType | ||
| from ai.chronon.query import Query, select | ||
|
|
||
|
|
||
| """ | ||
| This is the "left side" of the join that will comprise our training set. It is responsible for providing the primary keys | ||
| and timestamps for which features will be computed. | ||
| """ | ||
| source = Source( | ||
| events=EventSource( | ||
| table="data.checkouts", | ||
| query=Query( | ||
| selects=select("user_id"), | ||
| time_column="ts", | ||
| ) | ||
| )) | ||
|
|
||
| v1 = Model(source=source, outputSchema=TDataType(DataKind.DOUBLE), modelType=ModelType.XGBoost) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "outputSchema": { | ||
| "kind": 6 | ||
| }, | ||
| "modelType": 1, | ||
| "metaData": { | ||
| "name": "quickstart.test.v1", | ||
| "tableProperties": { | ||
| "source": "chronon" | ||
| }, | ||
| "outputNamespace": "default", | ||
| "team": "quickstart" | ||
| }, | ||
| "source": { | ||
| "events": { | ||
| "table": "data.checkouts", | ||
| "query": { | ||
| "selects": { | ||
| "user_id": "user_id" | ||
| }, | ||
| "timeColumn": "ts", | ||
| "setups": [] | ||
| } | ||
| } | ||
| }, | ||
| "modelParams": {} | ||
| } |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.