Skip to content

Commit b9dbb4d

Browse files
committed
docs: add a document of how to create InMemoryTarget
1 parent 4d9b033 commit b9dbb4d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/task_on_kart.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,24 @@ If you want to dump csv file with other encodings, you can use `encoding` parame
286286
def output(self):
287287
return self.make_target('file_name.csv', processor=CsvFileProcessor(encoding='cp932'))
288288
# This will dump csv as 'cp932' which is used in Windows.
289+
290+
Cache output in memory instead of dumping to files
291+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292+
You can use :class:`~InMemoryTarget` to cache output in memory instead of dumping to files by calling :func:`~gokart.target.make_inmemory_target`.
293+
294+
.. code:: python
295+
296+
from gokart.in_memory.target import make_inmemory_target
297+
298+
def output(self):
299+
unique_id = self.make_unique_id() if use_unique_id else None
300+
# TaskLock is not supported in InMemoryTarget, so it's dummy
301+
task_lock_params = make_task_lock_params(
302+
file_path='dummy_path',
303+
unique_id=unique_id,
304+
redis_host=None,
305+
redis_port=None,
306+
redis_timeout=self.redis_timeout,
307+
raise_task_lock_exception_on_collision=False,
308+
)
309+
return make_inmemory_target('dummy_path', task_lock_params, unique_id)

0 commit comments

Comments
 (0)