OpenAPI: Add blocking indexing thread pool option
This commit is contained in:
@@ -952,6 +952,7 @@ IndexingSettings Convert(const org::openapitools::server::model::Indexing_settin
|
||||
ret.RotationIndexing(input.isRotationIndexing());
|
||||
ret.RotationIndexingAngularStride_deg(input.getRotationIndexingAngularStrideDeg());
|
||||
ret.RotationIndexingMinAngularRange_deg(input.getRotationIndexingMinAngularRangeDeg());
|
||||
ret.BlockingBehavior(input.isBlocking());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -969,6 +970,7 @@ org::openapitools::server::model::Indexing_settings Convert(const IndexingSettin
|
||||
ret.setRotationIndexing(input.GetRotationIndexing());
|
||||
ret.setRotationIndexingAngularStrideDeg(input.GetRotationIndexingAngularStride_deg());
|
||||
ret.setRotationIndexingMinAngularRangeDeg(input.GetRotationIndexingMinAngularRange_deg());
|
||||
ret.setBlocking(input.GetBlockingBehavior());
|
||||
|
||||
org::openapitools::server::model::Geom_refinement_algorithm refinement;
|
||||
switch (input.GetGeomRefinementAlgorithm()) {
|
||||
|
||||
@@ -33,6 +33,8 @@ Indexing_settings::Indexing_settings()
|
||||
m_Rotation_indexing = false;
|
||||
m_Rotation_indexing_min_angular_range_deg = 20.0f;
|
||||
m_Rotation_indexing_angular_stride_deg = 0.5f;
|
||||
m_Blocking = false;
|
||||
m_BlockingIsSet = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -225,7 +227,7 @@ bool Indexing_settings::validate(std::stringstream& msg, const std::string& path
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -274,8 +276,11 @@ bool Indexing_settings::operator==(const Indexing_settings& rhs) const
|
||||
&&
|
||||
|
||||
(getRotationIndexingAngularStrideDeg() == rhs.getRotationIndexingAngularStrideDeg())
|
||||
&&
|
||||
|
||||
|
||||
((!blockingIsSet() && !rhs.blockingIsSet()) || (blockingIsSet() && rhs.blockingIsSet() && isBlocking() == rhs.isBlocking()))
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
@@ -301,6 +306,8 @@ void to_json(nlohmann::json& j, const Indexing_settings& o)
|
||||
j["rotation_indexing"] = o.m_Rotation_indexing;
|
||||
j["rotation_indexing_min_angular_range_deg"] = o.m_Rotation_indexing_min_angular_range_deg;
|
||||
j["rotation_indexing_angular_stride_deg"] = o.m_Rotation_indexing_angular_stride_deg;
|
||||
if(o.blockingIsSet())
|
||||
j["blocking"] = o.m_Blocking;
|
||||
|
||||
}
|
||||
|
||||
@@ -320,6 +327,11 @@ void from_json(const nlohmann::json& j, Indexing_settings& o)
|
||||
j.at("rotation_indexing").get_to(o.m_Rotation_indexing);
|
||||
j.at("rotation_indexing_min_angular_range_deg").get_to(o.m_Rotation_indexing_min_angular_range_deg);
|
||||
j.at("rotation_indexing_angular_stride_deg").get_to(o.m_Rotation_indexing_angular_stride_deg);
|
||||
if(j.find("blocking") != j.end())
|
||||
{
|
||||
j.at("blocking").get_to(o.m_Blocking);
|
||||
o.m_BlockingIsSet = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -435,6 +447,23 @@ void Indexing_settings::setRotationIndexingAngularStrideDeg(float const value)
|
||||
{
|
||||
m_Rotation_indexing_angular_stride_deg = value;
|
||||
}
|
||||
bool Indexing_settings::isBlocking() const
|
||||
{
|
||||
return m_Blocking;
|
||||
}
|
||||
void Indexing_settings::setBlocking(bool const value)
|
||||
{
|
||||
m_Blocking = value;
|
||||
m_BlockingIsSet = true;
|
||||
}
|
||||
bool Indexing_settings::blockingIsSet() const
|
||||
{
|
||||
return m_BlockingIsSet;
|
||||
}
|
||||
void Indexing_settings::unsetBlocking()
|
||||
{
|
||||
m_BlockingIsSet = false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace org::openapitools::server::model
|
||||
|
||||
@@ -129,6 +129,13 @@ public:
|
||||
/// </summary>
|
||||
float getRotationIndexingAngularStrideDeg() const;
|
||||
void setRotationIndexingAngularStrideDeg(float const value);
|
||||
/// <summary>
|
||||
/// Indexing in Jungfraujoch goes with a dedicated thread pool. If set to false, the thread pool is non-blocking, i.e. if there are no threads available, image indexing will be skipped. If set to true, the thread pool will block until a thread is available.
|
||||
/// </summary>
|
||||
bool isBlocking() const;
|
||||
void setBlocking(bool const value);
|
||||
bool blockingIsSet() const;
|
||||
void unsetBlocking();
|
||||
|
||||
friend void to_json(nlohmann::json& j, const Indexing_settings& o);
|
||||
friend void from_json(const nlohmann::json& j, Indexing_settings& o);
|
||||
@@ -161,6 +168,8 @@ protected:
|
||||
|
||||
float m_Rotation_indexing_angular_stride_deg;
|
||||
|
||||
bool m_Blocking;
|
||||
bool m_BlockingIsSet;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1917,6 +1917,13 @@ components:
|
||||
format: float
|
||||
default: 0.5
|
||||
minimum: 0
|
||||
blocking:
|
||||
type: boolean
|
||||
default: false
|
||||
description: |
|
||||
Indexing in Jungfraujoch goes with a dedicated thread pool.
|
||||
If set to false, the thread pool is non-blocking, i.e. if there are no threads available, image indexing will be skipped.
|
||||
If set to true, the thread pool will block until a thread is available.
|
||||
instrument_metadata:
|
||||
type: object
|
||||
description: "Metadata for a measurement instrument"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -200,3 +200,12 @@ float IndexingSettings::GetRotationIndexingAngularStride_deg() const {
|
||||
bool IndexingSettings::GetIndexIceRings() const {
|
||||
return index_ice_rings;
|
||||
}
|
||||
|
||||
bool IndexingSettings::GetBlockingBehavior() const {
|
||||
return blocking_behavior;
|
||||
}
|
||||
|
||||
IndexingSettings &IndexingSettings::BlockingBehavior(bool input) {
|
||||
blocking_behavior = input;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class IndexingSettings {
|
||||
int64_t indexing_threads = 4;
|
||||
int64_t viable_cell_min_spots = 9;
|
||||
|
||||
bool blocking_behavior = true;
|
||||
bool index_ice_rings = false;
|
||||
|
||||
bool enable_rotation_indexing = false;
|
||||
@@ -49,6 +50,7 @@ public:
|
||||
IndexingSettings& RotationIndexing(bool input);
|
||||
IndexingSettings& RotationIndexingMinAngularRange_deg(float input);
|
||||
IndexingSettings& RotationIndexingAngularStride_deg(float input);
|
||||
IndexingSettings& BlockingBehavior(bool input);
|
||||
|
||||
[[nodiscard]] int64_t GetViableCellMinSpots() const;
|
||||
[[nodiscard]] IndexingAlgorithmEnum GetAlgorithm() const;
|
||||
@@ -66,6 +68,7 @@ public:
|
||||
[[nodiscard]] bool GetRotationIndexing() const;
|
||||
[[nodiscard]] float GetRotationIndexingMinAngularRange_deg() const;
|
||||
[[nodiscard]] float GetRotationIndexingAngularStride_deg() const;
|
||||
[[nodiscard]] bool GetBlockingBehavior() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ Name | Type | Description | Notes
|
||||
**rotation_indexing** | **bool** | | [default to False]
|
||||
**rotation_indexing_min_angular_range_deg** | **float** | | [default to 20.0]
|
||||
**rotation_indexing_angular_stride_deg** | **float** | | [default to 0.5]
|
||||
**blocking** | **bool** | Indexing in Jungfraujoch goes with a dedicated thread pool. If set to false, the thread pool is non-blocking, i.e. if there are no threads available, image indexing will be skipped. If set to true, the thread pool will block until a thread is available. | [optional] [default to False]
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "jungfraujoch-frontend",
|
||||
"version": "1.0.0-rc.133",
|
||||
"version": "1.0.0-rc.135",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "jungfraujoch-frontend",
|
||||
"version": "1.0.0-rc.133",
|
||||
"version": "1.0.0-rc.135",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.4",
|
||||
|
||||
@@ -29,7 +29,7 @@ type MyState = {
|
||||
thread_count_error: boolean,
|
||||
unit_cell_dist_tolerance_error: boolean,
|
||||
rotation_indexing_min_angular_range_deg_error: boolean,
|
||||
rotation_indexing_angular_stride_deg_error: boolean,
|
||||
rotation_indexing_angular_stride_deg_error: boolean
|
||||
}
|
||||
|
||||
const default_indexing_settings: indexing_settings = {
|
||||
@@ -46,7 +46,8 @@ const default_indexing_settings: indexing_settings = {
|
||||
index_ice_rings: false,
|
||||
rotation_indexing: false,
|
||||
rotation_indexing_angular_stride_deg: 0.5,
|
||||
rotation_indexing_min_angular_range_deg: 20.0
|
||||
rotation_indexing_min_angular_range_deg: 20.0,
|
||||
blocking: false
|
||||
};
|
||||
|
||||
class IndexingSettings extends Component<MyProps, MyState> {
|
||||
@@ -219,6 +220,19 @@ class IndexingSettings extends Component<MyProps, MyState> {
|
||||
}
|
||||
label="Index ice rings"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={this.state.s.blocking}
|
||||
onChange={(event) => {
|
||||
this.setState(prevState => ({
|
||||
s: {...prevState.s, blocking: event.target.checked}
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label="Blocking thread pool"
|
||||
/>
|
||||
<b>Rotation (3D) indexing settings</b>
|
||||
<Stack spacing={2} direction="row" sx={{width: '80%'}}>
|
||||
|
||||
|
||||
@@ -55,5 +55,12 @@ export type indexing_settings = {
|
||||
rotation_indexing: boolean;
|
||||
rotation_indexing_min_angular_range_deg: number;
|
||||
rotation_indexing_angular_stride_deg: number;
|
||||
/**
|
||||
* Indexing in Jungfraujoch goes with a dedicated thread pool.
|
||||
* If set to false, the thread pool is non-blocking, i.e. if there are no threads available, image indexing will be skipped.
|
||||
* If set to true, the thread pool will block until a thread is available.
|
||||
*
|
||||
*/
|
||||
blocking?: boolean;
|
||||
};
|
||||
|
||||
|
||||
@@ -180,11 +180,11 @@ IndexerThread::~IndexerThread() {
|
||||
Finalize();
|
||||
}
|
||||
|
||||
IndexerThreadPool::IndexerThreadPool(const IndexingSettings &settings, bool blocking)
|
||||
IndexerThreadPool::IndexerThreadPool(const IndexingSettings &settings)
|
||||
: worker_busy(settings.GetIndexingThreads(), 0),
|
||||
worker_free_count(settings.GetIndexingThreads()),
|
||||
viable_cell_min_spots(settings.GetViableCellMinSpots()),
|
||||
blocking(blocking) {
|
||||
blocking(settings.GetBlockingBehavior()) {
|
||||
for (size_t i = 0; i < settings.GetIndexingThreads(); ++i)
|
||||
tasks.emplace_back(std::make_unique<IndexerThread>(std::cref(settings), i));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class IndexerThreadPool {
|
||||
const bool blocking;
|
||||
int GetFreeWorker();
|
||||
public:
|
||||
IndexerThreadPool(const IndexingSettings& settings, bool blocking = true);
|
||||
IndexerThreadPool(const IndexingSettings& settings);
|
||||
IndexerResult Run(const DiffractionExperiment& experiment, const std::vector<Coord>& recip);
|
||||
};
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ JFJochReceiverService &JFJochReceiverService::Indexing(const IndexingSettings &i
|
||||
|
||||
if (input.GetAlgorithm() != IndexingAlgorithmEnum::None) {
|
||||
logger.Info("Creating indexing thread pool...");
|
||||
indexer_thread_pool = std::make_unique<IndexerThreadPool>(input, false);
|
||||
indexer_thread_pool = std::make_unique<IndexerThreadPool>(input);
|
||||
logger.Info(" ... done");
|
||||
}
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user