C2W2 assignment error

I cannot find anything wrong with my code but the code keeps generating error and cannot submit the assignment

START CODE HERE

Instantiate ExampleGen with the input CSV dataset

example_gen = CsvExampleGen(input_base=_data_root)

Run the component using the InteractiveContext instance

context.run(example_gen)

END CODE HERE

#Error


RuntimeError Traceback (most recent call last)
in
5
6 # Run the component using the InteractiveContext instance
----> 7 context.run(example_gen)
8
9 ### END CODE HERE

/opt/conda/lib/python3.8/site-packages/tfx/orchestration/experimental/interactive/interactive_context.py in run_if_ipython(*args, **kwargs)
65 # IPYTHON variable is set by IPython, see
66 # IPython reference — IPython 0.10.2 documentation.
—> 67 return fn(*args, **kwargs)
68 else:
69 absl.logging.warning(

/opt/conda/lib/python3.8/site-packages/tfx/orchestration/experimental/interactive/interactive_context.py in run(self, component, enable_cache, beam_pipeline_args)
180 telemetry_utils.LABEL_TFX_RUNNER: runner_label,
181 }):
→ 182 execution_id = launcher.launch().execution_id
183
184 return execution_result.ExecutionResult(

/opt/conda/lib/python3.8/site-packages/tfx/orchestration/launcher/base_component_launcher.py in launch(self)
200 absl.logging.info(‘Running executor for %s’,
201 self._component_info.component_id)
→ 202 self._run_executor(execution_decision.execution_id,
203 execution_decision.input_dict,
204 execution_decision.output_dict,

/opt/conda/lib/python3.8/site-packages/tfx/orchestration/launcher/in_process_component_launcher.py in _run_executor(self, execution_id, input_dict, output_dict, exec_properties)
65 executor_context) # type: ignore
66
—> 67 executor.Do(input_dict, output_dict, exec_properties)

/opt/conda/lib/python3.8/site-packages/tfx/components/example_gen/base_example_gen_executor.py in Do(self, input_dict, output_dict, exec_properties)
294 logging.info(‘Generating examples.’)
295 with self._make_beam_pipeline() as pipeline:
→ 296 example_splits = self.GenerateExamplesByBeam(pipeline, exec_properties)
297
298 # pylint: disable=expression-not-assigned, no-value-for-parameter

/opt/conda/lib/python3.8/site-packages/tfx/components/example_gen/base_example_gen_executor.py in GenerateExamplesByBeam(self, pipeline, exec_properties)
226 buckets.append(total_buckets)
227 example_splits = (
→ 228 pipeline
229 | ‘InputToRecord’ >>
230 # pylint: disable=no-value-for-parameter

/opt/conda/lib/python3.8/site-packages/apache_beam/transforms/ptransform.py in ror(self, pvalueish, _unused)
1056
1057 def ror(self, pvalueish, _unused=None):
→ 1058 return self.transform.ror(pvalueish, self.label)
1059
1060 def expand(self, pvalue):

/opt/conda/lib/python3.8/site-packages/apache_beam/transforms/ptransform.py in ror(self, left, label)
571 pvalueish = _SetInputPValues().visit(pvalueish, replacements)
572 self.pipeline = p
→ 573 result = p.apply(self, pvalueish, label)
574 if deferred:
575 return result

/opt/conda/lib/python3.8/site-packages/apache_beam/pipeline.py in apply(self, transform, pvalueish, label)
644 try:
645 old_label, transform.label = transform.label, label
→ 646 return self.apply(transform, pvalueish)
647 finally:
648 transform.label = old_label

/opt/conda/lib/python3.8/site-packages/apache_beam/pipeline.py in apply(self, transform, pvalueish, label)
687 transform.type_check_inputs(pvalueish)
688
→ 689 pvalueish_result = self.runner.apply(transform, pvalueish, self._options)
690
691 if type_options is not None and type_options.pipeline_type_check:

/opt/conda/lib/python3.8/site-packages/apache_beam/runners/runner.py in apply(self, transform, input, options)
186 m = getattr(self, 'apply_s' cls.name, None)
187 if m:
→ 188 return m(transform, input, options)
189 raise NotImplementedError(
190 'Execution of [%s] not implemented in runner s.' (transform, self))

/opt/conda/lib/python3.8/site-packages/apache_beam/runners/runner.py in apply_PTransform(self, transform, input, options)
216 def apply_PTransform(self, transform, input, options):
217 # The base case of apply is to call the transform’s expand.
→ 218 return transform.expand(input)
219
220 def run_transform(self,

/opt/conda/lib/python3.8/site-packages/apache_beam/transforms/ptransform.py in expand(self, pcoll)
962 # Might not be a function.
963 pass
→ 964 return self._fn(pcoll, *args, **kwargs)
965
966 def default_label(self):

/opt/conda/lib/python3.8/site-packages/tfx/components/example_gen/csv_example_gen/executor.py in _CsvToExample(pipeline, exec_properties, split_pattern)
134 for csv_file in csv_files[1:]:
135 if io_utils.load_csv_column_names(csv_file) != column_names:
→ 136 raise RuntimeError(
137 ‘Files in same split {} have different header.’.format(csv_pattern))
138

RuntimeError: Files in same split metro_traffic_pipeline/data/* have different header.

Hi! Welcome to Discourse! Jupyter may have saved a .ipynb_checkpoints folder in your data directory. Remember that ExampleGen requires that all files under the directory and its subdirectories should follow the same format (i.e. the header column in your CSVs). You can remove the folder with this command: !rm -rf {_data_root}/.ipynb_checkpoints . After that, you should be able to ingest the data. Hope it works!