-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into benc-docs-polaris
- Loading branch information
Showing
15 changed files
with
262 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,35 @@ | ||
from parsl.errors import ParslError | ||
|
||
|
||
class DeserializationError(ParslError): | ||
"""Failure at the deserialization of results/exceptions from remote workers. | ||
""" | ||
|
||
def __init__(self, reason: str) -> None: | ||
self.reason = reason | ||
|
||
def __str__(self) -> str: | ||
return f"Failed to deserialize objects. Reason: {self.reason}" | ||
|
||
|
||
class SerializationError(ParslError): | ||
"""Failure to serialize task objects. | ||
""" | ||
|
||
def __init__(self, fname: str) -> None: | ||
self.fname = fname | ||
self.troubleshooting = "https://parsl.readthedocs.io/en/latest/faq.html#addressing-serializationerror" | ||
|
||
def __str__(self) -> str: | ||
return f"Failed to serialize objects for an invocation of function {self.fname}. Refer {self.troubleshooting}" | ||
|
||
|
||
class DeserializerPluginError(ParslError): | ||
"""Failure to dynamically load a deserializer plugin. | ||
""" | ||
|
||
def __init__(self, header: bytes) -> None: | ||
self.header = header | ||
|
||
def __str__(self) -> str: | ||
return f"Failed to load deserializer plugin for header {self.header!r}" |
This file contains 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 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,49 @@ | ||
import dill | ||
import io | ||
import typing as t | ||
|
||
from parsl.serialize.base import SerializerBase | ||
from proxystore.store import Store | ||
|
||
|
||
class ProxyStoreDeepPickler(dill.Pickler): | ||
"""This class extends dill so that certain objects will be stored into | ||
ProxyStore rather than serialized directly. The selection of objects is | ||
made by a user-specified policy. | ||
""" | ||
|
||
def __init__(self, *args: t.Any, should_proxy: t.Callable[[t.Any], bool], store: Store, **kwargs: t.Any) -> None: | ||
super().__init__(*args, **kwargs) | ||
self._store = store | ||
self._should_proxy = should_proxy | ||
|
||
def reducer_override(self, o: t.Any) -> t.Any: | ||
if self._should_proxy(o): | ||
proxy = self._store.proxy(o) | ||
return proxy.__reduce__() | ||
else: | ||
# fall through to dill | ||
return NotImplemented | ||
|
||
|
||
class ProxyStoreSerializer(SerializerBase): | ||
|
||
def __init__(self, *, should_proxy: t.Optional[t.Callable[[t.Any], bool]] = None, store: t.Optional[Store] = None) -> None: | ||
self._store = store | ||
self._should_proxy = should_proxy | ||
|
||
def serialize(self, data: t.Any) -> bytes: | ||
assert self._store is not None | ||
assert self._should_proxy is not None | ||
|
||
assert data is not None | ||
|
||
f = io.BytesIO() | ||
pickler = ProxyStoreDeepPickler(file=f, store=self._store, should_proxy=self._should_proxy) | ||
pickler.dump(data) | ||
return f.getvalue() | ||
|
||
def deserialize(self, body: bytes) -> t.Any: | ||
# because we aren't customising deserialization, use regular | ||
# dill for deserialization | ||
return dill.loads(body) |
This file contains 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
Oops, something went wrong.