@@ -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"
0 commit comments