{"record":{"id":"ca243f11de28012a","repo":"apache/beam","slug":"message-as-a-result-the-data-sequence-will-be-repeated-to","errorCode":null,"errorMessage":"{message} As a result, the data sequence will be repeated to generate elements for the entire duration.","messagePattern":"(.+?) As a result, the data sequence will be repeated to generate elements for the entire duration\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/python/apache_beam/transforms/periodicsequence.py","lineNumber":289,"sourceCode":"      stop_ts = self.stop_ts\n\n    # The total time for the impulse signal which occurs in [start, end).\n    impulse_duration = stop_ts - start_ts\n    if data_duration + Duration(self.interval) < impulse_duration:\n      # We don't have enough data for the impulse.\n      # If we can fit at least one more data point in the impulse duration,\n      # then we will be in the repeat mode.\n      message = 'The number of elements in the provided pre-timestamped ' \\\n        'data sequence is not enough to span the full impulse duration. ' \\\n        f'Expected duration: {impulse_duration}, ' \\\n        f'actual data duration: {data_duration}.'\n\n      if is_pre_timestamped:\n        raise ValueError(\n            f'{message} Please either provide more data or decrease '\n            '`stop_timestamp`.')\n      else:\n        warnings.warn(\n            f'{message} As a result, the data sequence will be repeated to '\n            'generate elements for the entire duration.')\n\n  def __init__(\n      self,\n      start_timestamp: TimestampTypes = Timestamp.now(),\n      stop_timestamp: TimestampTypes = MAX_TIMESTAMP,\n      fire_interval: float = 360.0,\n      apply_windowing: bool = False,\n      data: Optional[Sequence[Any]] = None,\n      rebase: RebaseMode = RebaseMode.REBASE_NONE):\n    '''\n    :param start_timestamp: Timestamp for first element.\n    :param stop_timestamp: Timestamp at or after which no elements will be\n      output.\n    :param fire_interval: Interval in seconds at which to output elements.\n    :param apply_windowing: Whether each element should be assigned to\n      individual window. If false, all elements will reside in global window.","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/periodicsequence.py#L271-L307","documentation":"PeriodicSequence validates that the provided data covers the requested [start, stop) duration. When the sequence's element timestamps do not extend to stop_timestamp and elements are not pre-timestamped, _validate_and_adjust_duration warns that the data will simply be repeated to keep emitting elements for the entire duration instead of raising (which happens when elements ARE pre-timestamped).","triggerScenarios":"Creating PeriodicSequence (or ImpulseSeqGen) with a stop_timestamp beyond the generated data's coverage without explicit per-element timestamps, so the source data is looped to fill the duration.","commonSituations":"Streaming test pipelines generating events from a finite list for a fixed test window; users supply fewer elements than the duration requires and are surprised by duplicated output.","solutions":["Provide more data elements so the sequence covers the full duration.","Decrease stop_timestamp to match the amount of data provided.","Ensure elements carry explicit (pre-)timestamps if you need exact end behavior — note that in that case a ValueError is raised instead of a warning.","If repetition is the desired behavior, ignore the warning."],"exampleFix":"# before\nPeriodicSequence(['a', 'b'], stop_timestamp=Timestamp.now() + 3600)  # repeats\n# after\nPeriodicSequence(['a', 'b'], stop_timestamp=Timestamp.now() + 10)","handlingStrategy":"validation","validationCode":"# Before building the sequence, ensure data covers the duration\nn_elements = len(data)\nrequired = (stop_timestamp - start_timestamp) / period\nif n_elements * period < (stop_timestamp - start_timestamp):\n    print('warning: not enough data for duration; elements will repeat')","typeGuard":null,"tryCatchPattern":"import warnings\nwith warnings.catch_warnings(record=True) as w:\n    warnings.simplefilter('always')\n    seq = PeriodicSequence(data, period=..., stop_timestamp=stop)\n    for warning in w:\n        if 'repeated' in str(warning.message):\n            print('data will repeat; add data or shorten stop_timestamp')","preventionTips":["Compute expected element count (duration / period) before building the sequence","Set stop_timestamp from data size rather than a fixed duration","Use pre-timestamped elements when exact coverage matters (fails fast instead of looping)"],"tags":["streaming","periodic-sequence","data-insufficient","repetition"],"backgroundTag":"value-out-of-range","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}