Add auto-generated pyi files to Metaflow#1557
Conversation
730671a to
59ca48c
Compare
59ca48c to
7a41cec
Compare
romain-intel
left a comment
There was a problem hiding this comment.
Added a few comments to make reviewing this easier.
| 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.
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+)
| return get_namespace() | ||
|
|
||
|
|
||
| MetaflowArtifacts = NamedTuple |
There was a problem hiding this comment.
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.
| super(DataArtifact, self).__setstate__(state) | ||
|
|
||
|
|
||
| class MetaflowData(object): |
There was a problem hiding this comment.
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.
Fixed adding optional
| return result | ||
|
|
||
| def __iter__(self) -> Iterable["MetaflowObject"]: | ||
| def __iter__(self) -> Iterator["MetaflowObject"]: |
There was a problem hiding this comment.
I changed all things that have yield to Yields in the docstring and also to return an Iterator (proper return type for yields).
| 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.
added proper type.
|
|
||
| MF Add To Current | ||
| ----------------- | ||
| trigger -> metaflow.events.Trigger |
There was a problem hiding this comment.
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.
TODO: unindent.
|
|
||
| MF Add To Current | ||
| ----------------- | ||
| project_name -> str |
There was a problem hiding this comment.
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.
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 |
savingoyal
left a comment
There was a problem hiding this comment.
lgtm - few minor comments
metaflow/client/core.py
Outdated
| Yields | ||
| ------ | ||
| Task | ||
| Control Task object for this step |
| 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.
MF Add To Current - is there a special significance to this string?
There was a problem hiding this comment.
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.
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.
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", |
| def step(f): | ||
| FlowSpecDerived = TypeVar("FlowSpecDerived", bound=FlowSpec) | ||
|
|
||
| StepFlag = NewType("StepFlag", bool) |
There was a problem hiding this comment.
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.