Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 5, 2023
1 parent 69e2d17 commit 037c346
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

# adapted from https://github.com/learnables/learn2learn/blob/master/examples/vision/protonet_miniimagenet.py#L154

"""## Train file https://www.dropbox.com/s/9g8c6w345s2ek03/mini-imagenet-cache-train.pkl?dl=1
## Validation File
Expand Down
16 changes: 7 additions & 9 deletions src/flash/core/serve/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,13 @@ def __call__(cls, *args, **kwargs):
class ModelComponent(metaclass=FlashServeMeta):
"""Represents a computation which is decorated by `@expose`.
A component is how we represent the main unit of work; it is a set of
evaluations which involve some input being passed through some set of
functions to generate some set of outputs.
To specify a component, we record things like: its name, source file
assets, configuration args, model source assets, etc. The
specification must be YAML serializable and loadable to/from a fully
initialized instance. It must contain the minimal set of information
necessary to find and initialize its dependencies (assets) and itself.
A component is how we represent the main unit of work; it is a set of evaluations which involve some input being
passed through some set of functions to generate some set of outputs.
To specify a component, we record things like: its name, source file assets, configuration args, model source
assets, etc. The specification must be YAML serializable and loadable to/from a fully initialized instance. It
must contain the minimal set of information necessary to find and initialize its dependencies (assets) and
itself.
"""

_flashserve_meta_: Optional[Union[BoundMeta, UnboundMeta]] = None
Expand Down
2 changes: 1 addition & 1 deletion src/flash/core/serve/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __str__(self):
return f"{self.component_uid}.{self.position}.{self.name}"

def __terminate_invalid_connection_request(self, other: "Parameter", dunder_meth_called: str) -> None:
"""verify that components can be composed.
"""Verify that components can be composed.
Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions src/flash/core/serve/dag/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def ishashable(x):


def istask(x):
"""Is x a runnable task?
A task is a tuple with a callable first argument
"""Is x a runnable task? A task is a tuple with a callable first argument.
Examples
--------
>>> istask((inc, 1))
Expand Down
2 changes: 1 addition & 1 deletion src/flash/core/serve/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def fn_outputs_to_keyed_map(serialize_fn_out_keys, fn_output) -> Dict[str, Any]:
"""convert outputs of a function to a dict of `{result_name: values}`
"""Convert outputs of a function to a dict of `{result_name: values}`
accepts function outputs which are sequence, dict, or object.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/flash/core/utilities/lightning_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class LightningArgumentParser(ArgumentParser):
def __init__(self, *args: Any, parse_as_dict: bool = True, **kwargs: Any) -> None:
"""Initialize argument parser that supports configuration file input.
For full details of accepted arguments see `ArgumentParser.__init__
<https://jsonargparse.readthedocs.io/en/stable/#jsonargparse.core.ArgumentParser.__init__>`_.
For full details of accepted arguments see
`ArgumentParser.__init__ <https://jsonargparse.readthedocs.io/en/stable/#jsonargparse.core.ArgumentParser.__init__>`_.
"""
super().__init__(*args, parse_as_dict=parse_as_dict, **kwargs)
self.add_argument(
Expand Down
1 change: 0 additions & 1 deletion src/flash/image/classification/integrations/learn2learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Note: This file will be deleted once
https://github.com/learnables/learn2learn/pull/257/files is merged within Learn2Learn.
Expand Down
52 changes: 12 additions & 40 deletions tests/core/serve/test_dag/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def test_avoid_broker_nodes(abcde):
b0 b1 b2
| \ /
a0 a1
| \ / a0 a1
a0 should be run before a1
"""
Expand Down Expand Up @@ -288,11 +287,7 @@ def test_prefer_short_dependents(abcde):
def test_run_smaller_sections(abcde):
r"""Testing structure.
aa
/ |
b d bb dd
/ \ /| | /
a c e cc
aa / | b d bb dd / \ /| | / a c e cc
Prefer to run acb first because then we can get that out of the way
"""
Expand Down Expand Up @@ -379,12 +374,9 @@ def _(*args):
def test_nearest_neighbor(abcde):
r"""Testing structure.
a1 a2 a3 a4 a5 a6 a7 a8 a9
\ | / \ | / \ | / \ | /
b1 b2 b3 b4
a1 a2 a3 a4 a5 a6 a7 a8 a9 \ | / \ | / \ | / \ | / b1 b2 b3 b4
Want to finish off a local group before moving on.
This is difficult because all groups are connected.
Want to finish off a local group before moving on. This is difficult because all groups are connected.
"""
a, b, c, _, _ = abcde
a1, a2, a3, a4, a5, a6, a7, a8, a9 = (a + i for i in "123456789")
Expand Down Expand Up @@ -512,14 +504,9 @@ def test_prefer_short_ancestor(abcde):
def test_map_overlap(abcde):
r"""Testing structure.
b1 b3 b5.
b1 b3 b5.
|\ / | \ / |
c1 c2 c3 c4 c5
|/ | \ | / | \|
d1 d2 d3 d4 d5
| | |
e1 e2 e5
|\ / | \ / | c1 c2 c3 c4 c5 |/ | \ | / | \| d1 d2 d3 d4 d5 | | | e1 e2 e5
Want to finish b1 before we start on e5
"""
Expand Down Expand Up @@ -667,29 +654,14 @@ def test_order_empty():
def test_switching_dependents(abcde):
r"""Testing structure.
a7 a8 <-- do these last
| /
a6 e6
| /
a5 c5 d5 e5
| | / /
a4 c4 d4 e4
| \ | / /
a3 b3---/
|
a2
|
a1
|
a0 <-- start here
a7 a8 <-- do these last | / a6 e6 | / a5 c5 d5 e5 | | / / a4 c4 d4
e4 | \ | / / a3 b3---/ | a2 | a1 | a0 <-- start here
Test that we are able to switch to better dependents.
In this graph, we expect to start at a0. To compute a4, we need to compute b3.
After computing b3, three "better" paths become available.
Confirm that we take the better paths before continuing down `a` path.
Test that we are able to switch to better dependents. In this graph, we expect to start at a0. To compute a4, we
need to compute b3. After computing b3, three "better" paths become available. Confirm that we take the better paths
before continuing down `a` path.
This test is pretty specific to how `order` is implemented
and is intended to increase code coverage.
This test is pretty specific to how `order` is implemented and is intended to increase code coverage.
"""
a, b, c, d, e = abcde
dsk = {
Expand Down

0 comments on commit 037c346

Please sign in to comment.