Downloads sample document files from non-restricted AWS S3 bucket.
(over_write=False)
| 73 | """ |
| 74 | @staticmethod |
| 75 | def load_sample_files(over_write=False): |
| 76 | |
| 77 | """ Downloads sample document files from non-restricted AWS S3 bucket. """ |
| 78 | |
| 79 | if not os.path.exists(LLMWareConfig.get_llmware_path()): |
| 80 | LLMWareConfig.setup_llmware_workspace() |
| 81 | |
| 82 | # not configurable - will pull into /sample_files under llmware_path |
| 83 | sample_files_path = os.path.join(LLMWareConfig.get_llmware_path(), "sample_files") |
| 84 | |
| 85 | if not os.path.exists(sample_files_path): |
| 86 | os.makedirs(sample_files_path,exist_ok=True) |
| 87 | else: |
| 88 | if not over_write: |
| 89 | logger.info(f"Setup - sample_files path already exists - {sample_files_path}") |
| 90 | return sample_files_path |
| 91 | |
| 92 | # pull from sample files bucket |
| 93 | logger.info(f"Setup - sample_files - downloading requested sample files from AWS S3 bucket - may take a minute.") |
| 94 | |
| 95 | bucket_name = LLMWareConfig().get_config("llmware_sample_files_bucket") |
| 96 | remote_zip = bucket_name + ".zip" |
| 97 | local_zip = os.path.join(sample_files_path, bucket_name + ".zip") |
| 98 | |
| 99 | CloudBucketManager().pull_file_from_public_s3(remote_zip, local_zip, bucket_name) |
| 100 | shutil.unpack_archive(local_zip, sample_files_path, "zip") |
| 101 | os.remove(local_zip) |
| 102 | |
| 103 | return sample_files_path |
| 104 | |
| 105 | @staticmethod |
| 106 | def load_voice_sample_files(over_write=False, small_only=True): |