From 40fb7cfffcd0e7ca506da4294efe1f2267d7b260 Mon Sep 17 00:00:00 2001 From: Luke Lombardi Date: Thu, 11 Jan 2024 16:43:58 -0500 Subject: [PATCH] add docstring for map --- sdk/src/beam/abstractions/map.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sdk/src/beam/abstractions/map.py b/sdk/src/beam/abstractions/map.py index d3c31d472..452d34b4c 100644 --- a/sdk/src/beam/abstractions/map.py +++ b/sdk/src/beam/abstractions/map.py @@ -15,6 +15,37 @@ class Map(BaseAbstraction): def __init__(self, *, name: str) -> None: + """ + A distributed python dictionary. + + Use this a concurrency safe key/value store, accessible both locally and within + remote containers. Serialization is done using cloudpickle, so any object that supported + by that should work here. The interface is that of a standard python dictionary. + + Because this is backed by a distributed dictionary, it will persist between runs. + + Parameters: + name (str): + The name of the map (any arbitrary string). + + Example: + ```python + from beam import Map + + m = Map(name="test") + + m["some_key"] = True + m["another_key"] = True + + print(m["somekey"]) + del m["somekey"] + + for k, v in m.items(): + print("key: ", k) + print("value: ", v) + + ``` + """ super().__init__() self.name: str = name