-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactored Subdir Metadata * Plugged downloader into subdirdata * Simplified Donwloader APIs * Added DownloadMonitor and plugged it into channel_loader * Simplified subdir API * Fixed python bindings * Changes according to review (on going) * Added json parsers to subdirmetadata
- Loading branch information
1 parent
146827c
commit 474be8b
Showing
22 changed files
with
1,599 additions
and
1,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2019, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
#ifndef MAMBA_CORE_DOWNLOAD_PROGRESS_BAR_HPP | ||
#define MAMBA_CORE_DOWNLOAD_PROGRESS_BAR_HPP | ||
|
||
#include <chrono> | ||
#include <functional> | ||
#include <vector> | ||
|
||
#include "mamba/core/context.hpp" | ||
#include "mamba/core/download.hpp" | ||
|
||
namespace mamba | ||
{ | ||
struct MonitorOptions | ||
{ | ||
bool checking_download = false; | ||
bool no_clear_progress_bar = false; | ||
}; | ||
|
||
class DownloadProgressBar : public DownloadMonitor | ||
{ | ||
public: | ||
|
||
static bool can_monitor(const Context& context); | ||
|
||
explicit DownloadProgressBar(MonitorOptions options = {}); | ||
virtual ~DownloadProgressBar() = default; | ||
|
||
DownloadProgressBar(const DownloadProgressBar&) = delete; | ||
DownloadProgressBar& operator=(const DownloadProgressBar&) = delete; | ||
|
||
DownloadProgressBar(DownloadProgressBar&&) = delete; | ||
DownloadProgressBar& operator=(DownloadProgressBar&&) = delete; | ||
|
||
void reset_options(MonitorOptions options); | ||
|
||
private: | ||
|
||
void observe_impl(MultiDownloadRequest& requests, DownloadOptions& options) override; | ||
void on_done_impl() override; | ||
void on_unexpected_termination_impl() override; | ||
|
||
void update_progress_bar(std::size_t index, const DownloadEvent& event); | ||
void update_progress_bar(std::size_t index, const DownloadProgress& progress); | ||
void update_progress_bar(std::size_t index, const DownloadError& error); | ||
void update_progress_bar(std::size_t index, const DownloadSuccess& success); | ||
|
||
void complete_checking_progress_bar(std::size_t index); | ||
|
||
std::function<void(ProgressBarRepr&)> download_repr(std::size_t index); | ||
|
||
using time_point = std::chrono::steady_clock::time_point; | ||
std::vector<time_point> m_throttle_time; | ||
std::vector<ProgressProxy> m_progress_bar; | ||
MonitorOptions m_options; | ||
}; | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.