diff --git a/firecrest/AsyncClient.py b/firecrest/AsyncClient.py index 2928c0a..d715291 100644 --- a/firecrest/AsyncClient.py +++ b/firecrest/AsyncClient.py @@ -833,6 +833,7 @@ async def compress( machine: str, source_path: str, target_path: str, + dereference: bool = False, fail_on_timeout: bool = True ) -> str: """Compress files using gzip compression. @@ -849,10 +850,17 @@ async def compress( .. warning:: This is available only for FirecREST>=1.16.0 """ + data: dict[str, str | bool] = { + "targetPath": target_path, + "sourcePath": source_path, + } + if dereference: + data["dereference"] = dereference + resp = await self._post_request( endpoint="/utilities/compress", additional_headers={"X-Machine-Name": machine}, - data={"targetPath": target_path, "sourcePath": source_path}, + data=data, ) # - If the response is 201, the request was successful so we can # return the target path @@ -876,7 +884,8 @@ async def compress( job_info = await self.submit_compress_job( machine, source_path, - target_path + target_path, + dereference ) jobid = job_info['jobid'] active_jobs = await self.poll_active( @@ -1032,7 +1041,7 @@ async def stat( :param machine: the machine name where the filesystem belongs to :param target_path: the absolute target path - :param dereference: follow link (default False) + :param dereference: follow symbolic links :calls: GET `/utilities/stat` """ params: dict[str, Any] = {"targetPath": target_path} @@ -1617,6 +1626,7 @@ async def _internal_transfer( account, ret_response, extension=None, + dereference=False, ): data = {"targetPath": target_path} if source_path: @@ -1637,6 +1647,9 @@ async def _internal_transfer( if extension: data["extension"] = extension + if dereference: + data["dereference"] = dereference + resp = await self._post_request( endpoint=endpoint, additional_headers={"X-Machine-Name": machine}, data=data ) @@ -1734,6 +1747,7 @@ async def submit_compress_job( machine: str, source_path: str, target_path: str, + dereference: bool = False, job_name: Optional[str] = None, time: Optional[str] = None, stage_out_job_id: Optional[str] = None, @@ -1746,6 +1760,7 @@ async def submit_compress_job( :param machine: the machine name where the scheduler belongs to :param source_path: the absolute source path :param target_path: the absolute target path + :param dereference: follow symbolic links :param job_name: job name :param time: limit on the total run time of the job. Acceptable time formats 'minutes', 'minutes:seconds', 'hours:minutes:seconds', 'days-hours', 'days-hours:minutes' and 'days-hours:minutes:seconds'. :param stage_out_job_id: transfer data after job with ID {stage_out_job_id} is completed @@ -1768,6 +1783,7 @@ async def submit_compress_job( stage_out_job_id, account, resp, + dereference=dereference, ) logger.info(f"Job submission task: {json_response['task_id']}") t = ComputeTask(self, json_response["task_id"], resp) diff --git a/firecrest/BasicClient.py b/firecrest/BasicClient.py index 18b9ae4..45c583e 100644 --- a/firecrest/BasicClient.py +++ b/firecrest/BasicClient.py @@ -600,6 +600,7 @@ def compress( machine: str, source_path: str, target_path: str, + dereference: bool = False, fail_on_timeout: bool = True ) -> str: """Compress files using gzip compression. @@ -617,10 +618,17 @@ def compress( .. warning:: This is available only for FirecREST>=1.16.0 """ + data: dict[str, str | bool] = { + "targetPath": target_path, + "sourcePath": source_path + } + if dereference: + data["dereference"] = dereference + resp = self._post_request( endpoint="/utilities/compress", additional_headers={"X-Machine-Name": machine}, - data={"targetPath": target_path, "sourcePath": source_path}, + data=data, ) # - If the response is 201, the request was successful so we can # return the target path @@ -644,7 +652,8 @@ def compress( job_info = self.submit_compress_job( machine, source_path, - target_path + target_path, + dereference ) jobid = job_info['jobid'] active_jobs = self.poll_active( @@ -801,7 +810,7 @@ def stat( :param machine: the machine name where the filesystem belongs to :param target_path: the absolute target path - :param dereference: follow link (default False) + :param dereference: follow symbolic links :calls: GET `/utilities/stat` """ params: dict[str, Any] = {"targetPath": target_path} @@ -1416,6 +1425,7 @@ def _internal_transfer( stage_out_job_id, account, extension=None, + dereference=False, ): data = {"targetPath": target_path} if source_path: @@ -1436,6 +1446,9 @@ def _internal_transfer( if extension: data["extension"] = extension + if dereference: + data["dereference"] = dereference + resp = self._post_request( endpoint=endpoint, additional_headers={"X-Machine-Name": machine}, data=data ) @@ -1651,6 +1664,7 @@ def submit_compress_job( machine: str, source_path: str, target_path: str, + dereference: bool = False, job_name: Optional[str] = None, time: Optional[str] = None, stage_out_job_id: Optional[str] = None, @@ -1663,6 +1677,7 @@ def submit_compress_job( :param machine: the machine name where the scheduler belongs to :param source_path: the absolute source path :param target_path: the absolute target path + :param dereference: follow symbolic links :param job_name: job name :param time: limit on the total run time of the job. Acceptable time formats 'minutes', 'minutes:seconds', 'hours:minutes:seconds', 'days-hours', 'days-hours:minutes' and 'days-hours:minutes:seconds'. :param stage_out_job_id: transfer data after job with ID {stage_out_job_id} is completed @@ -1684,6 +1699,7 @@ def submit_compress_job( time, stage_out_job_id, account, + dereference=dereference, ) logger.info(f"Job submission task: {json_response['task_id']}") return self._poll_tasks( diff --git a/firecrest/cli/__init__.py b/firecrest/cli/__init__.py index 243caa9..f3ccc92 100644 --- a/firecrest/cli/__init__.py +++ b/firecrest/cli/__init__.py @@ -1256,7 +1256,13 @@ def submit_compress( try: console.print( client.submit_compress_job( - system, source, destination, job_name, time, jobid, account + machine=system, + source_path=source, + target_path=destination, + job_name=job_name, + time=time, + stage_out_job_id=jobid, + account=account ) ) except Exception as e: