def log_artifact(self, local_file, artifact_path=None): verify_artifact_path(artifact_path) file_name = os.path.basename(local_file) paths = (artifact_path, file_name) if artifact_path else (file_name, ) url = posixpath.join(self.artifact_uri, *paths) with open(local_file, "rb") as f: resp = self._session.put(url, data=f, timeout=600) resp.raise_for_status()
def log_artifacts(self, local_dir, artifact_path=None): verify_artifact_path(artifact_path) # NOTE: The artifact_path is expected to be in posix format. # Posix paths work fine on windows but just in case we normalize it here. if artifact_path: artifact_path = os.path.normpath(artifact_path) artifact_dir = os.path.join(self.artifact_dir, artifact_path) if artifact_path else \ self.artifact_dir if not os.path.exists(artifact_dir): mkdir(artifact_dir) dir_util.copy_tree(src=local_dir, dst=artifact_dir)
def log_artifact(self, local_file, artifact_path=None): verify_artifact_path(artifact_path) file_name = os.path.basename(local_file) paths = (artifact_path, file_name) if artifact_path else (file_name, ) endpoint = posixpath.join("/", *paths) with open(local_file, "rb") as f: resp = http_request(self._host_creds, endpoint, "PUT", data=f, timeout=600) augmented_raise_for_status(resp)
def log_artifact(self, local_file, artifact_path=None): verify_artifact_path(artifact_path) # NOTE: The artifact_path is expected to be in posix format. # Posix paths work fine on windows but just in case we normalize it here. if artifact_path: artifact_path = os.path.normpath(artifact_path) artifact_dir = os.path.join(self.artifact_dir, artifact_path) if artifact_path else \ self.artifact_dir if not os.path.exists(artifact_dir): mkdir(artifact_dir) shutil.copyfile( local_file, os.path.join(artifact_dir, os.path.basename(local_file)))