diff --git a/ads/jobs/serializer.py b/ads/jobs/serializer.py index 4c475fdb9..f0493b280 100644 --- a/ads/jobs/serializer.py +++ b/ads/jobs/serializer.py @@ -12,11 +12,9 @@ import yaml from ads.common.auth import default_signer +# Special type to represent the current enclosed class. +# This type is used by factory class method or when a method returns ``self``. Self = TypeVar("Self", bound="Serializable") -"""Special type to represent the current enclosed class. - -This type is used by factory class method or when a method returns ``self``. -""" class Serializable(ABC): @@ -72,6 +70,14 @@ def _write_to_file(s: str, uri: str, **kwargs) -> None: "if you wish to overwrite." ) + # Add default signer if the uri is an object storage uri, and + # the user does not specify config or signer. + if ( + uri.startswith("oci://") + and "config" not in kwargs + and "signer" not in kwargs + ): + kwargs.update(default_signer()) with fsspec.open(uri, "w", **kwargs) as f: f.write(s) diff --git a/pyproject.toml b/pyproject.toml index 28560e6e0..045599f60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ dependencies = [ "asteval>=0.9.25", "cerberus>=1.3.4", "cloudpickle>=1.6.0", - "fsspec>=0.8.7", + "fsspec>=0.8.7,<2023.9.1", # v2.9.1 introduced issues, releved by unit tests "gitpython>=3.1.2", "jinja2>=2.11.2", "matplotlib>=3.1.3", diff --git a/tests/integration/jobs/test_dsc_job.py b/tests/integration/jobs/test_dsc_job.py index e317de67e..2cbd616ee 100644 --- a/tests/integration/jobs/test_dsc_job.py +++ b/tests/integration/jobs/test_dsc_job.py @@ -222,11 +222,10 @@ def assert_job_creation(self, job, expected_infra_spec, expected_runtime_spec): random.seed(threading.get_ident() + os.getpid()) random_suffix = "".join(random.choices(string.ascii_uppercase, k=6)) yaml_uri = f"oci://{self.BUCKET}@{self.NAMESPACE}/tests/{timestamp}/example_job_{random_suffix}.yaml" - config_path = "~/.oci/config" - job.to_yaml(uri=yaml_uri, config=config_path) + job.to_yaml(uri=yaml_uri) print(f"Job YAML saved to {yaml_uri}") try: - job = Job.from_yaml(uri=yaml_uri, config=config_path) + job = Job.from_yaml(uri=yaml_uri) except Exception: self.fail(f"Failed to load job from YAML\n{traceback.format_exc()}")