-
Notifications
You must be signed in to change notification settings - Fork 789
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
Add auto-generated pyi files to Metaflow #1557
Conversation
730671a
to
59ca48c
Compare
59ca48c
to
7a41cec
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.
Added a few comments to make reviewing this easier.
@@ -1,14 +1,13 @@ | |||
from collections import namedtuple | |||
import os | |||
from typing import Any, Optional | |||
from typing import Any, Optional, TYPE_CHECKING |
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.
note: for full disclosure, TYPE_CHECKING was introduced in 3.5.2. I feel it should still be OK and we can still support 3.5 (just 3.5.2+)
@@ -203,6 +213,9 @@ def default_namespace() -> str: | |||
return get_namespace() | |||
|
|||
|
|||
MetaflowArtifacts = NamedTuple |
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.
This is just to give it a proper type so that there are no issues in the generated pyi file. It's not very informative but I don't think we can do much better.
@@ -981,6 +950,50 @@ def __setstate__(self, state): | |||
super(DataArtifact, self).__setstate__(state) | |||
|
|||
|
|||
class MetaflowData(object): |
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.
Moved below to allow types to find each other.
self, | ||
stream: str, | ||
as_unicode: bool = True, | ||
meta_dict: Optional[Dict[str, Any]] = None, |
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.
Fixed adding optional
@@ -337,17 +350,17 @@ def _get_object(self, *path_components): | |||
raise MetaflowNotFound("%s does not exist" % self) | |||
return result | |||
|
|||
def __iter__(self) -> Iterable["MetaflowObject"]: | |||
def __iter__(self) -> Iterator["MetaflowObject"]: |
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.
I changed all things that have yield to Yields
in the docstring and also to return an Iterator (proper return type for yields).
@@ -143,7 +143,7 @@ def __init__( | |||
content_type: Optional[str] = None, | |||
metadata: Optional[Dict[str, str]] = None, | |||
range_info: Optional[RangeInfo] = None, | |||
last_modified: int = None, | |||
last_modified: Optional[int] = None, |
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.
added proper type.
|
||
MF Add To Current | ||
----------------- | ||
trigger -> metaflow.events.Trigger |
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.
notice that both decorators can add the same thing. The definitions should be the same (one is just picked -- no checks). It will say that this applies to BOTH decorators.
metaflow/plugins/events_decorator.py
Outdated
|
||
Returns | ||
------- | ||
Trigger |
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.
TODO: unindent.
|
||
MF Add To Current | ||
----------------- | ||
project_name -> str |
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.
add multiple properties. Blank line between properties is optional I think but makes things clearer.
stubs/setup.py
Outdated
@@ -0,0 +1,46 @@ | |||
from setuptools import find_packages, setup | |||
|
|||
version = "2.10.2" |
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.
we should probably read this from common location.
cbefb45
to
48ca1fa
Compare
Now: - deals with static and class methods - better handling of forward types or types and files with __annotations__ - better handling of default values
aa3c5ec
to
211d6e2
Compare
Testing[602] @ 7b279fa |
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.
lgtm - few minor comments
metaflow/client/core.py
Outdated
Yields | ||
------ | ||
Task | ||
Control Task object for this step |
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.
nit - objects
@@ -25,6 +25,50 @@ class ProjectDecorator(FlowDecorator): | |||
Project name. Make sure that the name is unique amongst all | |||
projects that use the same production scheduler. The name may | |||
contain only lowercase alphanumeric characters and underscores. | |||
|
|||
MF Add To Current |
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.
MF Add To Current
- is there a special significance to this string?
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.
Yes, this is used to define a section to add fields to the current object. It's non standard and just our thing.
stubs/setup.py
Outdated
include_package_data=True, | ||
name="metaflow-stubs", | ||
version=version, | ||
description="Metaflow: More Data Science, Less Engineering", |
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.
Change the description to notate that this is a stubs package
stubs/setup.py
Outdated
name="metaflow-stubs", | ||
version=version, | ||
description="Metaflow: More Data Science, Less Engineering", | ||
long_description=open("../README.md").read(), |
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.
This long description does not apply to this package
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", |
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.
3.12?
def step(f): | ||
FlowSpecDerived = TypeVar("FlowSpecDerived", bound=FlowSpec) | ||
|
||
StepFlag = NewType("StepFlag", bool) |
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.
Can you add some comments here around the necessity for StepFlag
?
* Added a stub command; moved script to new location. * validation of sample flow with mypy + packaging (#1676) * validate sample flow with mypy * also install metaflow in CI * change commands * package generated stubs with metaflow * don't do editable install * re-introduce setup.py * update publish action * point to dist * check common cases with pytest-mypy plugin * Updated stub tests; added kw only args to stub generator * remove test flow * kubernetes validity * add tests for environment, card, catch, conda * add tests for timeout, secrets, retry, resources decorators * add tests for conda_base, schedule, trigger, trigger_on_finish decorators * Get tests to pass again --------- Co-authored-by: Romain Cledat <[email protected]> * fix checking of stubs package (#1689) * Properly uninstall packages that provide stubs before installing a new one. * Add a few more cases to the stub generator * add tests for pypi and pypi_base decorators (#1694) * Remove print; better setup.py --------- Co-authored-by: madhur-ob <[email protected]>
* use regex for mypy tests * fix regex
* separate workflow for testing stubs * remove 3.5 and 3.6
* install build via pip * install pytest
No description provided.