From 48af853f0493fc81ec960f28fb54ff6d01ef0163 Mon Sep 17 00:00:00 2001 From: Hana Joo Date: Fri, 21 Aug 2026 11:01:40 -0700 Subject: [PATCH] Add Pyrefly supppressions PiperOrigin-RevId: 968587724 --- README.md | 1 - src/python/tensorflow_cloud/core/containerize.py | 14 +++++++------- .../tensorflow_cloud/core/experimental/models.py | 2 +- src/python/tensorflow_cloud/core/preprocess.py | 2 +- src/python/tensorflow_cloud/core/run.py | 12 ++++++------ .../tensorflow_cloud/tuner/cloud_fit_client.py | 6 +++--- src/python/tensorflow_cloud/tuner/tuner.py | 8 ++++---- src/python/tensorflow_cloud/tuner/utils.py | 2 +- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 407417b8..9997443f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -# ⛔️ DEPRECATED - This repo is no longer maintained. # TensorFlow Cloud The TensorFlow Cloud repository provides APIs that will allow to easily go from diff --git a/src/python/tensorflow_cloud/core/containerize.py b/src/python/tensorflow_cloud/core/containerize.py index 3704916a..b305a324 100644 --- a/src/python/tensorflow_cloud/core/containerize.py +++ b/src/python/tensorflow_cloud/core/containerize.py @@ -94,8 +94,8 @@ def __init__( self.project_id = gcp.get_project_name() # Those will be populated lazily. - self.tar_file_path: bytes | str = None - self.docker_client: docker.APIClient = None + self.tar_file_path: bytes | str = None # pyrefly: ignore[bad-assignment] + self.docker_client: docker.APIClient = None # pyrefly: ignore[bad-assignment] self.tar_file_descriptor = None self.docker_file_descriptor = None @@ -239,7 +239,7 @@ def _create_docker_file(self): ) docker_entry_point = self.preprocessed_entry_point or self.entry_point - _, docker_entry_point_file_name = os.path.split(docker_entry_point) + _, docker_entry_point_file_name = os.path.split(docker_entry_point) # pyrefly: ignore[no-matching-overload] # Using `ENTRYPOINT` here instead of `CMD` specifically because # we want to support passing user code flags. @@ -503,10 +503,10 @@ def _upload_tar_to_gcs(self): storage_client = storage.Client() try: bucket = storage_client.get_bucket( - self.docker_config.image_build_bucket) + self.docker_config.image_build_bucket) # pyrefly: ignore[missing-attribute] except NotFound: bucket = storage_client.create_bucket( - self.docker_config.image_build_bucket) + self.docker_config.image_build_bucket) # pyrefly: ignore[missing-attribute] unique_tag = str(uuid.uuid4()).replace("-", "_") storage_object_name = "tf_cloud_train_tar_{}".format(unique_tag) @@ -542,7 +542,7 @@ def _create_cloud_build_request_dict( cache_from = (self.docker_config.cache_from or self.docker_config.image) - if cache_from: + if cache_from: # pyrefly: ignore[unbound-name] # Use the given Docker image as cache. request_dict["steps"].append({ "name": "gcr.io/cloud-builders/docker", @@ -560,7 +560,7 @@ def _create_cloud_build_request_dict( }) request_dict["source"] = { "storageSource": { - "bucket": self.docker_config.image_build_bucket, + "bucket": self.docker_config.image_build_bucket, # pyrefly: ignore[missing-attribute] "object": storage_object_name, } } diff --git a/src/python/tensorflow_cloud/core/experimental/models.py b/src/python/tensorflow_cloud/core/experimental/models.py index c48b7723..cbabe599 100644 --- a/src/python/tensorflow_cloud/core/experimental/models.py +++ b/src/python/tensorflow_cloud/core/experimental/models.py @@ -295,7 +295,7 @@ def get_original_lines(): """Gets the file lines of models_entry_point.py as a list of strings.""" with pkg_resources.files(__package__).joinpath( _ENTRY_POINT_TEMPLATE - ).open('rt') as file: + ).open('rt') as file: # pyrefly: ignore[no-matching-overload] lines = file.readlines() return lines diff --git a/src/python/tensorflow_cloud/core/preprocess.py b/src/python/tensorflow_cloud/core/preprocess.py index d0b1e8d1..a5885403 100644 --- a/src/python/tensorflow_cloud/core/preprocess.py +++ b/src/python/tensorflow_cloud/core/preprocess.py @@ -207,7 +207,7 @@ def get_preprocessed_entry_point( ) # Get the python code from the iPython notebook. - (py_content, _) = PythonExporter().from_filename(entry_point) + (py_content, _) = PythonExporter().from_filename(entry_point) # pyrefly: ignore[bad-argument-type] py_content = py_content.splitlines(keepends=True) # Remove any iPython special commands and add the python code diff --git a/src/python/tensorflow_cloud/core/run.py b/src/python/tensorflow_cloud/core/run.py index 30bdca0e..0de1f574 100644 --- a/src/python/tensorflow_cloud/core/run.py +++ b/src/python/tensorflow_cloud/core/run.py @@ -233,9 +233,9 @@ def run( worker_config = machine_config.COMMON_MACHINE_CONFIGS["T4_1X"] if docker_config == "auto": docker_config = docker_config_module.DockerConfig() - docker_config.parent_image = (docker_config.parent_image or + docker_config.parent_image = (docker_config.parent_image or # pyrefly: ignore[missing-attribute] docker_base_image) - docker_config.image_build_bucket = (docker_config.image_build_bucket or + docker_config.image_build_bucket = (docker_config.image_build_bucket or # pyrefly: ignore[missing-attribute] docker_image_bucket_name) # Working directory in the Docker container filesystem. @@ -255,11 +255,11 @@ def run( worker_count, entry_point_args, stream_logs, - docker_config.image_build_bucket, + docker_config.image_build_bucket, # pyrefly: ignore[missing-attribute] called_from_notebook, job_labels=job_labels or {}, service_account=service_account, - docker_parent_image=docker_config.parent_image, + docker_parent_image=docker_config.parent_image, # pyrefly: ignore[missing-attribute] ) print("Validation was successful.") @@ -296,7 +296,7 @@ def run( "docker_config": docker_config, "called_from_notebook": called_from_notebook, } - if docker_config.image_build_bucket is None: + if docker_config.image_build_bucket is None: # pyrefly: ignore[missing-attribute] container_builder = containerize.LocalContainerBuilder( *cb_args, **cb_kwargs) else: @@ -306,7 +306,7 @@ def run( # Delete all the temporary files we created. if preprocessed_entry_point is not None: - os.close(pep_file_descriptor) + os.close(pep_file_descriptor) # pyrefly: ignore[unbound-name] os.remove(preprocessed_entry_point) for file_path, file_descriptor in container_builder.get_generated_files( return_descriptors=True): diff --git a/src/python/tensorflow_cloud/tuner/cloud_fit_client.py b/src/python/tensorflow_cloud/tuner/cloud_fit_client.py index 154fb23f..2411b816 100644 --- a/src/python/tensorflow_cloud/tuner/cloud_fit_client.py +++ b/src/python/tensorflow_cloud/tuner/cloud_fit_client.py @@ -109,8 +109,8 @@ def cloud_fit( else: job_spec = _default_job_spec( - region=region, - image_uri=image_uri, + region=region, # pyrefly: ignore[bad-argument-type] + image_uri=image_uri, # pyrefly: ignore[bad-argument-type] entry_point_args=[ "--remote_dir", remote_dir, @@ -231,7 +231,7 @@ def _default_job_spec( training_inputs["masterConfig"] = {"imageUri": image_uri} training_inputs["workerCount"] = DEFAULT_NUM_WORKERS job_spec = {"trainingInput": training_inputs} - job_spec["job_id"] = "cloud_fit_{}".format( + job_spec["job_id"] = "cloud_fit_{}".format( # pyrefly: ignore[bad-assignment] datetime.datetime.now().strftime("%Y%m%d%H%M%S") ) return job_spec diff --git a/src/python/tensorflow_cloud/tuner/tuner.py b/src/python/tensorflow_cloud/tuner/tuner.py index b1e9d8d0..64198c9e 100644 --- a/src/python/tensorflow_cloud/tuner/tuner.py +++ b/src/python/tensorflow_cloud/tuner/tuner.py @@ -279,7 +279,7 @@ def update_trial(self, """Used by a worker to report the status of a trial.""" # Constructs the measurement. # Adds the measurement of the objective functions to a trial. - elapsed_secs = time.time() - self._start_time + elapsed_secs = time.time() - self._start_time # pyrefly: ignore[unsupported-operation] if elapsed_secs < 0 or step < 0: raise ValueError( "Both elapsed_secs and step must be non-negative.") @@ -294,7 +294,7 @@ def update_trial(self, if ob_name in metrics: metric_list.append( {"metric": ob_name, - "value": float(metrics.get(ob_name))} + "value": float(metrics.get(ob_name))} # pyrefly: ignore[bad-argument-type] ) tf.get_logger().info( 'Objective "{}" is not found in metrics.'.format(ob.name) @@ -302,7 +302,7 @@ def update_trial(self, continue metric_list.append( - {"metric": ob.name, "value": float(metrics.get(ob.name))} + {"metric": ob.name, "value": float(metrics.get(ob.name))} # pyrefly: ignore[bad-argument-type] ) self.service.report_intermediate_objective_value( @@ -775,7 +775,7 @@ def _get_job_spec_from_config(self, job_id: Text) -> Dict[Text, Any]: An AI Platform Training job spec. """ # Set worker count as one less replica as one is dedicated as master - worker_count = self._replica_count -1 + worker_count = self._replica_count -1 # pyrefly: ignore[unsupported-operation] worker_config = None if worker_count > 0: worker_config = self._replica_config diff --git a/src/python/tensorflow_cloud/tuner/utils.py b/src/python/tensorflow_cloud/tuner/utils.py index 248fc7ea..1afb3d66 100644 --- a/src/python/tensorflow_cloud/tuner/utils.py +++ b/src/python/tensorflow_cloud/tuner/utils.py @@ -405,7 +405,7 @@ def format_objective( ] if isinstance(objective, list): if isinstance(objective[0], oracle_module.Objective): - return objective + return objective # pyrefly: ignore[bad-return] if isinstance(objective[0], str): return [ oracle_module.Objective(