Accumulate without emit/output

Abierto
#417 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

Start with the linked Accumulating State documentation and the accumulate and partition APIs. Reproduce the example using returns_state=True and a conditional emission, then determine whether accumulate supports suppressing output directly. Done means the requested behavior is implemented or the documentation clearly explains the supported approach, with coverage for both emitted and suppressed values.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

According to the documentation of accumulate (Accumulating State), it is possible to not have accumulate "output" anything:

One piece of data comes in, either one or zero pieces go out.

I tried to come up with a way to use this to "group" values together: collect values as they come in and emit a list "every now and then".

Basically I have something along the lines of this now:

stream = streamz.Stream()
grouped = stream.accumulate(my_group, returns_state=True, start={}).filter(non_empty)


def my_group(state, row):
    ...
    if <condition>:
        return state, [<collected_rows>]
    else:
        return state, None

def non_empty(row):
    if row:
        return True
    return False

But I think the .filter(non_empty) part should not be necessary. I should be able to not return (output) a value unless I emit a list in my_group, no? Would that not be the "zero pieces go out" case?

Note: I realised in the meantime that I might be able to achieve what I need using partition, but the question remains (for other use cases): how can I not emit (or output) a value from accumulate?

Lenguaje dominante
Python
Estrellas
1.3k
Forks
149
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-streamz/streamz

Todos los issues de python-streamz/streamz

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.