Skip to content

Commit 34f6ef9

Browse files
committed
WIP - breakage
1 parent 5d2328a commit 34f6ef9

File tree

6 files changed

+22
-86
lines changed

6 files changed

+22
-86
lines changed

dcpy/connectors/edm/builds.py

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ def storage(self) -> PathedStorageConnector:
6565
)
6666
return self._storage
6767

68-
@storage.setter
69-
def storage(self, value: PathedStorageConnector) -> None:
70-
"""Allow setting storage directly (useful for testing)."""
71-
self._storage = value
72-
7368
@staticmethod
7469
def create() -> "BuildsConnector":
7570
"""Create a BuildsConnector with lazy-loaded S3 storage."""
@@ -85,37 +80,14 @@ def _generate_metadata(self) -> dict[str, str]:
8580
metadata["run-url"] = git.action_url()
8681
return metadata
8782

88-
def _upload(
89-
self,
90-
output_path: Path,
91-
build_key: BuildKey,
92-
*,
93-
acl: s3.ACL | None,
94-
max_files: int = s3.MAX_FILE_COUNT,
95-
) -> None:
96-
"""Upload build output(s) to build folder in edm-publishing"""
97-
meta = self._generate_metadata()
98-
if not output_path.is_dir():
99-
raise Exception(
100-
"'_upload' expects output_path to be a directory, not a file"
101-
)
102-
103-
# Use PathedStorageConnector's push method to upload the folder
104-
self.storage.push(
105-
key=build_key.path,
106-
filepath=str(output_path),
107-
acl=str(acl),
108-
metadata=meta,
109-
)
110-
11183
def _upload_build(
11284
self,
113-
output_path: Path,
85+
build_dir: Path,
11486
product: str,
11587
*,
11688
acl: s3.ACL | None = None,
117-
build: str | None = None,
118-
max_files: int = s3.MAX_FILE_COUNT,
89+
build_name: str | None = None,
90+
# max_files: int = s3.MAX_FILE_COUNT, # TODO
11991
) -> BuildKey:
12092
"""
12193
Uploads a product build to an S3 bucket using cloudpathlib.
@@ -129,35 +101,40 @@ def _upload_build(
129101
FileNotFoundError: If the provided output_path does not exist.
130102
ValueError: If the build name is not provided and cannot be found in the environment variables.
131103
"""
132-
if not output_path.exists():
133-
raise FileNotFoundError(f"Path {output_path} does not exist")
134-
build_name = build or BUILD_NAME
104+
if not build_dir.exists():
105+
raise FileNotFoundError(f"Path {build_dir} does not exist")
106+
build_name = build_name or BUILD_NAME
135107
if not build_name:
136108
raise ValueError(
137109
f"Build name supplied via CLI or the env var 'BUILD_NAME' cannot be '{build_name}'."
138110
)
139111
build_key = BuildKey(product, build_name)
140-
logger.info(f'Uploading {output_path} to {build_key.path} with ACL "{acl}"')
141-
self._upload(output_path, build_key, acl=acl, max_files=max_files)
112+
113+
logger.info(f'Uploading {build_dir} to {build_key.path} with ACL "{acl}"')
114+
self.storage.push(
115+
key=build_key.path,
116+
filepath=str(build_dir),
117+
acl=str(acl),
118+
metadata=self._generate_metadata(),
119+
)
142120

143121
return build_key
144122

145-
def push(self, key: str, **kwargs) -> dict:
123+
def push_versioned(self, key: str, version: str, **kwargs) -> dict:
124+
# For builds, the "version" is the build name/ID
146125
connector_args = kwargs["connector_args"]
147-
148-
logger.info(
149-
f"Pushing build for product: {key}, with note: {connector_args['build_note']}"
150-
)
151126
acl = (
152127
s3.string_as_acl(connector_args["acl"])
153128
if connector_args.get("acl")
154129
else None
155130
)
131+
132+
logger.info(f"Pushing build for product: {key}, build: {version}")
156133
result = self._upload_build(
157-
output_path=kwargs["build_path"],
134+
build_dir=kwargs["build_path"],
158135
product=key,
159136
acl=acl,
160-
build=connector_args["build_note"],
137+
build_name=version,
161138
)
162139
return asdict(result)
163140

@@ -200,29 +177,6 @@ def pull_versioned(
200177
) -> dict:
201178
return self._pull(key, version, destination_path, **kwargs)
202179

203-
def push_versioned(self, key: str, version: str, **kwargs) -> dict:
204-
# For builds, the "version" is the build name/ID
205-
connector_args = kwargs["connector_args"]
206-
207-
logger.info(f"Pushing build for product: {key}, build: {version}")
208-
result = self._upload_build(
209-
output_path=kwargs["build_path"],
210-
product=key,
211-
acl=s3.string_as_acl(connector_args["acl"]),
212-
build=version,
213-
)
214-
return asdict(result)
215-
216-
def pull(
217-
self,
218-
key: str,
219-
destination_path: Path,
220-
**kwargs,
221-
) -> dict:
222-
raise Exception(
223-
"Use pull_versioned() instead - BuildsConnector requires a specific build version"
224-
)
225-
226180
def list_versions(self, key: str, *, sort_desc: bool = True, **kwargs) -> list[str]:
227181
"""List all build versions (build names) for a product."""
228182
build_folder_key = f"{key}/build"

dcpy/connectors/edm/drafts.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ def storage(self) -> PathedStorageConnector:
5353
)
5454
return self._storage
5555

56-
@storage.setter
57-
def storage(self, value: PathedStorageConnector) -> None:
58-
"""Allow setting storage directly (useful for testing)."""
59-
self._storage = value
60-
6156
@staticmethod
6257
def create() -> "DraftsConnector":
6358
"""Create a DraftsConnector with lazy-loaded S3 storage."""

dcpy/connectors/edm/gis.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ def storage(self) -> PathedStorageConnector:
3939
)
4040
return self._storage
4141

42-
@storage.setter
43-
def storage(self, value: PathedStorageConnector) -> None:
44-
"""Allow setting storage directly (useful for testing)."""
45-
self._storage = value
46-
4742
@staticmethod
4843
def create() -> "GisDatasetsConnector":
4944
"""Create a GisDatasetsConnector with lazy-loaded S3 storage."""

dcpy/connectors/edm/published.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ def storage(self) -> PathedStorageConnector:
5151
)
5252
return self._storage
5353

54-
@storage.setter
55-
def storage(self, value: PathedStorageConnector) -> None:
56-
"""Allow setting storage directly (useful for testing)."""
57-
self._storage = value
58-
5954
@staticmethod
6055
def create() -> "PublishedConnector":
6156
"""Create a PublishedConnector with lazy-loaded S3 storage."""

dcpy/lifecycle/builds/artifacts/builds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ def upload(
128128
meta = _generate_metadata(running_in_gha=CI) # for now, same thing.
129129

130130
logger.info(f"Uploading {output_path} to {build_key.path}")
131-
result = get_builds_default_connector().push(
131+
result = get_builds_default_connector().push_versioned(
132132
key=product,
133+
version=build_name,
133134
build_path=output_path,
134135
connector_args={"build_note": build_name, "acl": acl, "metadata": meta},
135136
)

dcpy/test_integration/connectors/edm/test_builds_conn.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ def _test_builds_connector_error_cases(conn: BuildsConnector, tmp_path):
143143
):
144144
conn.get_latest_version(existing_product)
145145

146-
# Test pull should raise Exception
147-
with pytest.raises(Exception, match="Use pull_versioned"):
148-
conn.pull(existing_product, tmp_path / "dummy")
149-
150146
# Test pulling non-existent file
151147
destination_dir = tmp_path / "downloads" / "test_error"
152148
destination_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)