C3_W1_Lab_2_TFX_Tuner_and_Trainer seems to be working incorrect

Hello!

C3_W1_Lab_2_TFX_Tuner_and_Trainer seems to be working incorrect

cell:

# Run the component. This will take around 10 minutes to run.
# When done, it will summarize the results and show the 10 best trials.
context.run(tuner, enable_cache=False)

produces error:

TypeError                                 Traceback (most recent call last)
<ipython-input-22-84c03f958263> in <cell line: 3>()
      1 # Run the component. This will take around 10 minutes to run.
      2 # When done, it will summarize the results and show the 10 best trials.
----> 3 context.run(tuner, enable_cache=False)

6 frames
/usr/local/lib/python3.9/dist-packages/tfx/orchestration/experimental/interactive/notebook_utils.py in run_if_ipython(*args, **kwargs)
     29       # __IPYTHON__ variable is set by IPython, see
     30       # https://ipython.org/ipython-doc/rel-0.10.2/html/interactive/reference.html#embedding-ipython.
---> 31       return fn(*args, **kwargs)
     32     else:
     33       logging.warning(

/usr/local/lib/python3.9/dist-packages/tfx/orchestration/experimental/interactive/interactive_context.py in run(self, component, enable_cache, beam_pipeline_args)
    162         telemetry_utils.LABEL_TFX_RUNNER: runner_label,
    163     }):
--> 164       execution_id = launcher.launch().execution_id
    165 
    166     return execution_result.ExecutionResult(

/usr/local/lib/python3.9/dist-packages/tfx/orchestration/launcher/base_component_launcher.py in launch(self)
    204       # be immutable in this context.
    205       # output_dict can still be changed, specifically properties.
--> 206       self._run_executor(execution_decision.execution_id,
    207                          copy.deepcopy(execution_decision.input_dict),
    208                          execution_decision.output_dict,

/usr/local/lib/python3.9/dist-packages/tfx/orchestration/launcher/in_process_component_launcher.py in _run_executor(self, execution_id, input_dict, output_dict, exec_properties)
     71     # be immutable in this context.
     72     # output_dict can still be changed, specifically properties.
---> 73     executor.Do(
     74         copy.deepcopy(input_dict), output_dict, copy.deepcopy(exec_properties))

/usr/local/lib/python3.9/dist-packages/tfx/components/tuner/executor.py in Do(self, input_dict, output_dict, exec_properties)
    122     tuner = search(input_dict, exec_properties, self._get_tmp_dir())
    123 
--> 124     write_best_hyperparameters(tuner, output_dict)

/usr/local/lib/python3.9/dist-packages/tfx/components/tuner/executor.py in write_best_hyperparameters(tuner, output_dict)
     73   # Saves tuner results in pandas `records` format (list of rows).
     74   results = []
---> 75   for trial_obj in tuner.oracle.get_best_trials(tuner.oracle.max_trials):
     76     if trial_obj.status == trial.TrialStatus.COMPLETED and trial_obj.hyperparameters.values:
     77       results.append({

/usr/local/lib/python3.9/dist-packages/keras_tuner/engine/oracle.py in get_best_trials(self, num_trials)
    512         )
    513 
--> 514         if len(sorted_trials) < num_trials:
    515             sorted_trials = sorted_trials + [
    516                 t

TypeError: '<' not supported between instances of 'int' and 'NoneType'

after several time of searching

i have the same error

Thanks for bringing this up.
The staff have been informed to fix the lab.

Hi everyone and welcome to the community! Thank you for reporting this. There’s currently a conflict with TFX and the latest version of Keras Tuner. We added a line in the pip install cell to roll it back to a compatible version. You can re-open the lab from the classroom to see the changes. Thanks again!

Hello Chris! :smiley:
Hope you are fine. I wonder how did you set up the environment to solve this issue. I saw what version were used on the Coursera Lab, but unable to install them as when installing TFX 1.12.0 it says:
ERROR: Ignored the following versions that require a different python version: 0.12.0rc0 Requires-Python >=2.7,<3; 0.24.0 Requires-Python >=3.6,<3.9; 0.24.0rc0 Requires-Python >=3.6,<3.9; 0.24.0rc1 Requires-Python >=3.6,<3.9;

ERROR: No matching distribution found for tfx==1.12.0

Please help, I want to replicate the environment in Google Colab.