Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import molequeue client #596

Merged
merged 4 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ option(USE_LIBMSYM "Enable optional features using libmsym" ON)
option(USE_SPGLIB "Enable optional features using spglib" ON)
option(USE_MMTF "Enable optional features using mmtf" ON)
option(USE_PROTOCALL "Enable libraries that use ProtoCall" OFF)
option(USE_MOLEQUEUE "Enable the MoleQueue dependent functionality" ON)
option(USE_PYTHON "Use Python to wrap some of our API" OFF)

add_subdirectory(utilities)
Expand Down
7 changes: 3 additions & 4 deletions avogadro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ if(USE_QT)
add_subdirectory(qtopengl)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/qtopengl)
endif()
if(USE_MOLEQUEUE)
add_subdirectory(molequeue)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/molequeue)
endif()
# Add unconditionally as this talks to MoleQueue, but doesn't depend on it.
add_subdirectory(molequeue)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/molequeue)
if(USE_VTK)
add_subdirectory(vtk)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/vtk)
Expand Down
9 changes: 4 additions & 5 deletions avogadro/molequeue/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Pull in MoleQueue
find_package(MoleQueue REQUIRED NO_MODULE)
include_directories(${MoleQueue_INCLUDE_DIRS})

find_package(Eigen3 REQUIRED)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
Expand Down Expand Up @@ -29,6 +25,9 @@ set(SOURCES
molequeuemanager.cpp
molequeuequeuelistmodel.cpp
molequeuewidget.cpp
client/client.cpp
client/jobobject.cpp
client/jsonrpcclient.cpp
)

set(UIS
Expand All @@ -42,4 +41,4 @@ list(APPEND SOURCES ${UI_SOURCES})

avogadro_add_library(AvogadroMoleQueue ${HEADERS} ${SOURCES})
set_target_properties(AvogadroMoleQueue PROPERTIES AUTOMOC TRUE)
target_link_libraries(AvogadroMoleQueue AvogadroQtGui MoleQueueClient Qt5::Widgets Qt5::Network)
target_link_libraries(AvogadroMoleQueue AvogadroQtGui Qt5::Widgets Qt5::Network)
21 changes: 4 additions & 17 deletions avogadro/molequeue/batchjob.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2013 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/

#include "batchjob.h"
Expand All @@ -21,8 +10,6 @@

#include <limits>

using MoleQueue::JobObject;

namespace Avogadro {
namespace MoleQueue {

Expand Down Expand Up @@ -78,7 +65,7 @@ BatchJob::BatchId BatchJob::submitNextJob(const Core::Molecule& mol)
BatchId bId = m_jobObjects.size();

// Create the job object:
::MoleQueue::JobObject job;
JobObject job;
job.fromJson(m_moleQueueOptions);
job.setDescription(
tr("Batch Job #%L1 (%2)").arg(bId + 1).arg(job.description()));
Expand Down Expand Up @@ -119,7 +106,7 @@ bool BatchJob::lookupJob(BatchId bId)
if (!mqManager.connectIfNeeded())
return false;

::MoleQueue::Client& client = mqManager.client();
Client& client = mqManager.client();
RequestId rId = client.lookupJob(sId);
m_requests.insert(rId, Request(Request::LookupJob, bId));
return true;
Expand Down Expand Up @@ -223,7 +210,7 @@ void BatchJob::setup()
}

MoleQueueManager& mqManager = MoleQueueManager::instance();
::MoleQueue::Client& client = mqManager.client();
Client& client = mqManager.client();
connect(&client, SIGNAL(submitJobResponse(int, uint)),
SLOT(handleSubmissionReply(int, uint)));
connect(&client, SIGNAL(lookupJobResponse(int, QJsonObject)),
Expand Down
29 changes: 9 additions & 20 deletions avogadro/molequeue/batchjob.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2013 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/

#ifndef AVOGADRO_QTGUI_BATCHJOB_H
Expand All @@ -23,7 +12,7 @@

#include <avogadro/core/avogadrocore.h>

#include <molequeue/client/jobobject.h>
#include "client/jobobject.h"

#include <QtCore/QJsonObject>
#include <QtCore/QMap>
Expand Down Expand Up @@ -107,7 +96,7 @@ class AVOGADROMOLEQUEUE_EXPORT BatchJob : public QObject
*/
void setMoleQueueOptions(const QJsonObject& opts);
QJsonObject moleQueueOptions() const;
::MoleQueue::JobObject moleQueueJobTemplate() const;
JobObject moleQueueJobTemplate() const;
/**@}*/

/**
Expand Down Expand Up @@ -138,7 +127,7 @@ class AVOGADROMOLEQUEUE_EXPORT BatchJob : public QObject
* @return The most recent JobObject for the job with the batch id @a batchId.
* These are updated for each change in job state.
*/
::MoleQueue::JobObject jobObject(BatchId batchId) const;
JobObject jobObject(BatchId batchId) const;

/**
* @return True if @a state corresponds to a job that is finished running.
Expand Down Expand Up @@ -237,7 +226,7 @@ private slots:
QJsonObject m_moleQueueOptions;

/// Cached job states.
QList<::MoleQueue::JobObject> m_jobObjects;
QList<JobObject> m_jobObjects;
/// Lookup batch ids from server ids.
QMap<ServerId, BatchId> m_serverIds;
/// Job states. For fast lookups without string conversions.
Expand Down Expand Up @@ -270,9 +259,9 @@ inline QJsonObject BatchJob::moleQueueOptions() const
return m_moleQueueOptions;
}

inline ::MoleQueue::JobObject BatchJob::moleQueueJobTemplate() const
inline JobObject BatchJob::moleQueueJobTemplate() const
{
::MoleQueue::JobObject result;
JobObject result;
result.fromJson(m_moleQueueOptions);
return result;
}
Expand Down Expand Up @@ -306,9 +295,9 @@ inline BatchJob::ServerId BatchJob::serverId(BatchJob::BatchId id) const
: InvalidServerId;
}

inline ::MoleQueue::JobObject BatchJob::jobObject(BatchJob::BatchId id) const
inline JobObject BatchJob::jobObject(BatchJob::BatchId id) const
{
return id < m_jobObjects.size() ? m_jobObjects[id] : ::MoleQueue::JobObject();
return id < m_jobObjects.size() ? m_jobObjects[id] : JobObject();
}

inline bool BatchJob::isTerminal(BatchJob::JobState state)
Expand Down
Loading