Skip to content
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

Added typing information for all public APIs #1158

Merged
merged 21 commits into from
Feb 9, 2023

Conversation

romain-intel
Copy link
Contributor

The docstrings were also slightly more standardized.

Only public facing APIs had the type information added to them.

There are a few minor bug fixes in the default values for some functions (namely using [] as a default value (replaced with None)) as well as removing default values where it does not make sense (S3.info() for example). There should be no other functional change.

The docstrings were also slightly more standardized.

Only public facing APIs had the type information added to them.

There are a few minor bug fixes in the default values for some functions
(namely using [] as a default value (replaced with None)) as well
as removing default values where it does not make sense (S3.info() for example).
There should be no other functional change.
@romain-intel romain-intel requested a review from tuulos October 5, 2022 06:31
@romain-intel
Copy link
Contributor Author

I have a typo -- will fix.

@romain-intel
Copy link
Contributor Author

I am still working on this to make it fully compatible with the dev command being developed. It's mostly formatting the strings and what not but want to do it only once :).

metaflow/includefile.py Outdated Show resolved Hide resolved
tmproot: str = ".",
bucket: Optional[str] = None,
prefix: Optional[str] = None,
run: Optional[Union[FlowSpec, TRun]] = None,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been staring at this for a moment. Why the use of a TypeVar? I know these can be used for generics to enhance autocompletion when using subclasses.

Example:

from typing import Generic, TypeVar
from dataclasses import dataclass
from .some_file import Weapon

TWeapon = TypeVar("TWeapon", bound=Weapon)

@dataclass
class Enemy(Generic[TWeapon]):
    holding: TWeapon

enemy = Enemy(holding=...some weapon subclass instance)
enemy.holding # gives autocompletion for the specific subclass of Weapon in holding

Is that somehow what's going on with TRun? Does Union[type, type] simply require TypeVar objects rather than the string representation, i.e. "Run"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try with "Run". I have to check it works on 3.5 too. IIRC that may be why I went this route but may have been delusional :) .

metaflow/flowspec.py Outdated Show resolved Hide resolved
@phitoduck
Copy link

@romain-intel thanks for taking this on! Fingers crossed this gets accepted :)

@romain-intel
Copy link
Contributor Author

Thanks for the review. I need to rebase this and clean it up some more but yes, I am also hoping we can get this in. @tuulos , what do you think?

@romain-intel
Copy link
Contributor Author

sorry for the delay @phitoduck -- I am back to working on this to address your comments, update and hopefully merge soon :).

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ 5e8e6dc

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ 5e8e6dc had 15 FAILUREs.

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ d3f515a

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ 302d7b4

Iterator over `Run` objects in this flow.
"""
return self._filtered_children(*tags)


class Metaflow(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reasons to move this object to the end? Are there any diffs here that I should be looking into?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needed Flow iirc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no change.

@@ -50,19 +50,14 @@ def unquote_bytes(x):

from shlex import quote as _quote

if sys.version_info >= (3, 7):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the context for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I could use NamedTuple and have the proper types.

`@resources` is also present, the maximum value from all decorators is
used.
image : str
image : str, optional, default: None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this default isn't wholly accurate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it as optional and described tthe behavior in the doc string.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior is symmetric to batch - so the comment should be quite similar here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stupid me -- I had modified it but forgot to save the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stupid me -- I had modified it but forgot to save the file.

Kubernetes service account to use when launching pod in Kubernetes.
namespace : str, default: METAFLOW_KUBERNETES_NAMESPACE
Kubernetes namespace to use when launching pod in Kubernetes.
secrets : List[str], optional, default: None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default would be METAFLOW_KUBERNETES_SECRETS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left to optional beceause the doc string and code actually add it to KUBERNETES_SECRETS

Kubernetes service account to use when launching pod in Kubernetes.
namespace : str, default: METAFLOW_KUBERNETES_NAMESPACE
Kubernetes namespace to use when launching pod in Kubernetes.
secrets : List[str], optional, default: None
Kubernetes secrets to use when launching pod in Kubernetes. These
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
in Metaflow configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default for tolerations would be METAFLOW_KUBERNETES_TOLERATIONS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change.

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ dac5fbe

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ 302d7b4 had 1 FAILURE.

@nflx-mf-bot
Copy link
Collaborator

Testing[313] @ dac5fbe PASSED

Copy link
Collaborator

@savingoyal savingoyal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple of nits waiting to be resolved. once those are addressed, we should be good to merge.

@romain-intel romain-intel merged commit 2f9e443 into master Feb 9, 2023
@romain-intel romain-intel deleted the fix/typing-for-public-api branch February 9, 2023 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants