Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/python/tensorflow_cloud/core/containerize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand All @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/python/tensorflow_cloud/core/experimental/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/python/tensorflow_cloud/core/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/python/tensorflow_cloud/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.")

Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions src/python/tensorflow_cloud/tuner/cloud_fit_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/python/tensorflow_cloud/tuner/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -294,15 +294,15 @@ 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)
)
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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/python/tensorflow_cloud/tuner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading