MCPcopy Create free account
hub / github.com/ml-explore/mlx-data / AWSFileFetcher

Class AWSFileFetcher

mlx/data/core/AWSFileFetcher.h:51–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49};
50
51class AWSFileFetcher : public FileFetcher {
52 public:
53 AWSFileFetcher(
54 const std::string& bucket,
55 const AWSFileFetcherOptions& opt = AWSFileFetcherOptions());
56
57 int64_t get_size(const std::string& filename) const;
58
59 virtual void backend_fetch(const std::string& filename) const override;
60 virtual void backend_erase(const std::string& filename) const override;
61
62 void update_credentials(
63 const std::string& access_key_id = "",
64 const std::string& secret_access_key = "",
65 const std::string& session_token = "",
66 const std::string& expiration = "") const;
67
68 void update_credentials_with_callback(
69 std::function<
70 std::tuple<std::string, std::string, std::string, std::string>()>
71 callback,
72 int64_t period = 0);
73
74 bool are_credentials_expired() const;
75
76 virtual ~AWSFileFetcher();
77
78 protected:
79 void check_credentials() const;
80
81 std::string bucket_;
82 std::filesystem::path prefix_;
83 std::filesystem::path local_prefix_;
84 std::unique_ptr<Aws::Client::ClientConfiguration> config_;
85 bool config_virtual_host_;
86 int64_t buffer_size_;
87 int num_threads_;
88 mutable std::unique_ptr<Aws::Auth::AWSCredentials> credentials_;
89 mutable std::unique_ptr<Aws::S3::S3Client> client_;
90 mutable std::atomic<bool> dtor_called_;
91 mutable std::shared_mutex client_mutex_;
92
93 // credentials periodic update
94 std::function<
95 std::tuple<std::string, std::string, std::string, std::string>()>
96 credentials_callback_;
97 int64_t credentials_period_;
98 mutable std::chrono::time_point<std::chrono::system_clock>
99 credentials_timestamp_;
100 mutable std::shared_mutex credentials_mutex_;
101};
102
103} // namespace core
104} // namespace data

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected