Skip to content
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
3 changes: 1 addition & 2 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
black>=24.4.2
# Lock to v18.x until we can upgrade our code to meet v19's formatting standards.
clang-format~=18.1
clang-format>=20.1.0
# Lock to v19.x until we can upgrade our code to fix new v20 issues.
clang-tidy~=19.1
ruff>=0.4.4
Expand Down
86 changes: 28 additions & 58 deletions lint-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tasks:
vars:
FLAGS: "--in-place"

cpp-configs: "tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh"
cpp-configs: "tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh"

cpp-check:
cmds:
Expand All @@ -45,51 +45,33 @@ tasks:
- task: "cpp-static-fix"

cpp-format-check:
sources: &cpp_format_src_files
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
- "{{.G_SRC_SPIDER_DIR}}/.clang-format"
- "{{.G_EXAMPLES_DIR}}/**/*.cpp"
- "{{.G_EXAMPLES_DIR}}/**/*.h"
- "{{.G_EXAMPLES_DIR}}/**/*.hpp"
- "{{.G_SRC_SPIDER_DIR}}/**/*.cpp"
- "{{.G_SRC_SPIDER_DIR}}/**/*.h"
- "{{.G_SRC_SPIDER_DIR}}/**/*.hpp"
- "{{.G_TEST_DIR}}/**/*.cpp"
- "{{.G_TEST_DIR}}/**/*.h"
- "{{.G_TEST_DIR}}/**/*.hpp"
sources: &cpp_source_files
- "{{.ROOT_DIR}}/.clang-format"
- "{{.ROOT_DIR}}/.clang-tidy"
- "{{.TASKFILE}}"
- "tools/yscope-dev-utils/lint-configs/.clang-format"
- "{{.G_SRC_SPIDER_DIR}}/.clang-format"
- "{{.G_EXAMPLES_DIR}}/**"
- "{{.G_SRC_SPIDER_DIR}}/**"
- "{{.G_TEST_DIR}}/**"
deps: ["cpp-configs", "venv"]
cmds:
- task: "clang-format"
vars:
FLAGS: "--dry-run"
SRC_DIR: "{{.G_SRC_SPIDER_DIR}}"
- task: "clang-format"
vars:
FLAGS: "--dry-run"
SRC_DIR: "{{.G_TEST_DIR}}"
- task: "clang-format"
- task: ":utils:cpp-lint:clang-format"
vars:
FLAGS: "--dry-run"
SRC_DIR: "{{.G_EXAMPLES_DIR}}"
FLAGS: ["--dry-run"]
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.inc"]
ROOT_PATHS: *cpp_source_files
VENV_DIR: "{{.G_LINT_VENV_DIR}}"

cpp-format-fix:
sources: *cpp_format_src_files
sources: *cpp_source_files
deps: ["cpp-configs", "venv"]
cmds:
- task: "clang-format"
- task: ":utils:cpp-lint:clang-format"
vars:
FLAGS: "-i"
SRC_DIR: "{{.G_SRC_SPIDER_DIR}}"
- task: "clang-format"
vars:
FLAGS: "-i"
SRC_DIR: "{{.G_TEST_DIR}}"
- task: "clang-format"
vars:
FLAGS: "-i"
SRC_DIR: "{{.G_EXAMPLES_DIR}}"
FLAGS: ["-i"]
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.inc"]
ROOT_PATHS: *cpp_source_files
VENV_DIR: "{{.G_LINT_VENV_DIR}}"

cpp-static-check:
# Alias task to `cpp-static-fix` since we don't currently support automatic fixes.
Expand All @@ -112,7 +94,7 @@ tasks:
- "{{.G_SPIDER_COMPILE_COMMANDS_DB}}"
- "{{.TASKFILE}}"
- "taskfile.yaml"
- "tools/yscope-dev-utils/lint-configs/.clang-tidy"
- "tools/yscope-dev-utils/exports/lint-configs/.clang-tidy"
deps: [":config-cmake-project", "cpp-configs", "venv"]
cmds:
- task: "clang-tidy"
Expand Down Expand Up @@ -165,7 +147,7 @@ tasks:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
yamllint \
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
--config-file "tools/yscope-dev-utils/exports/lint-configs/.yamllint.yml" \
--strict \
.gersemirc \
.github/ \
Expand All @@ -176,18 +158,6 @@ tasks:
taskfile.yaml \
test-tasks.yaml

clang-format:
internal: true
requires:
vars: ["FLAGS", "SRC_DIR"]
cmd: |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
find "{{.SRC_DIR}}" \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 --no-run-if-empty clang-format {{.FLAGS}} -Werror

clang-tidy:
internal: true
requires:
Expand Down Expand Up @@ -229,18 +199,18 @@ tasks:
run: "once"
deps:
- ":init"
- task: ":utils:validate-checksum"
- task: ":utils:checksum:validate"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
DATA_DIR: "{{.OUTPUT_DIR}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
cmds:
- task: ":utils:create-venv"
- task: ":utils:misc:create-venv"
vars:
LABEL: "lint"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
REQUIREMENTS_FILE: "lint-requirements.txt"
REQUIREMENTS_FILE: "{{.ROOT_DIR}}/lint-requirements.txt"
# This command must be last
- task: ":utils:compute-checksum"
- task: ":utils:checksum:compute"
vars:
DATA_DIR: "{{.OUTPUT_DIR}}"
OUTPUT_FILE: "{{.CHECKSUM_FILE}}"
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
1 change: 0 additions & 1 deletion src/spider/client/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "Exception.hpp"

namespace spider {

namespace core {
class Data;
class DataStorage;
Expand Down
2 changes: 0 additions & 2 deletions src/spider/client/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "Exception.hpp"

namespace spider {

Driver::Driver(std::string const& storage_url)
: m_storage_factory{std::make_shared<core::MySqlStorageFactory>(storage_url)} {
boost::uuids::random_generator gen;
Expand Down Expand Up @@ -126,5 +125,4 @@ auto Driver::kv_store_get(std::string const& key) -> std::optional<std::string>
}
return value;
}

} // namespace spider
8 changes: 4 additions & 4 deletions src/spider/client/Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class Driver {
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params, TaskIo... Inputs>
auto
start(TaskFunction<ReturnType, Params...> const& task, Inputs&&... inputs) -> Job<ReturnType> {
auto start(TaskFunction<ReturnType, Params...> const& task, Inputs&&... inputs)
-> Job<ReturnType> {
// Check input type
static_assert(
sizeof...(Inputs) == sizeof...(Params),
Expand Down Expand Up @@ -247,8 +247,8 @@ class Driver {
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params, TaskIo... Inputs>
auto
start(TaskGraph<ReturnType, Params...> const& graph, Inputs&&... inputs) -> Job<ReturnType> {
auto start(TaskGraph<ReturnType, Params...> const& graph, Inputs&&... inputs)
-> Job<ReturnType> {
// Check input type
static_assert(
sizeof...(Inputs) == sizeof...(Params),
Expand Down
9 changes: 6 additions & 3 deletions src/spider/client/Job.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class Job {
for_n<std::tuple_size_v<ReturnType>>([&](auto i) {
using T = std::tuple_element_t<i.cValue, ReturnType>;
if (task_index >= output_task_ids.size()) {
throw ConnectionException{fmt::format("Not enough output tasks for job result")
throw ConnectionException{
fmt::format("Not enough output tasks for job result")
};
}
core::Task const& task = tasks[task_index];
Expand Down Expand Up @@ -266,7 +267,8 @@ class Job {
msgpack::object const& obj = handle.get();
std::get<i.cValue>(result) = obj.as<T>();
} catch (msgpack::type_error const& e) {
throw ConnectionException{fmt::format("Failed to unpack data: {}", e.what())
throw ConnectionException{
fmt::format("Failed to unpack data: {}", e.what())
};
}
}
Expand Down Expand Up @@ -302,7 +304,8 @@ class Job {
}
err = m_data_storage->get_data(conn, optional_data_id.value(), &data);
if (!err.success()) {
throw ConnectionException{fmt::format("Failed to get data: {}", err.description)
throw ConnectionException{
fmt::format("Failed to get data: {}", err.description)
};
}
return core::DataImpl::create_data<DataType>(
Expand Down
2 changes: 0 additions & 2 deletions src/spider/client/TaskContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "Exception.hpp"

namespace spider {

auto TaskContext::get_id() const -> boost::uuids::uuid {
return m_task_id;
}
Expand Down Expand Up @@ -70,5 +69,4 @@ auto TaskContext::get_jobs() -> std::vector<boost::uuids::uuid> {
}
return job_ids;
}

} // namespace spider
8 changes: 4 additions & 4 deletions src/spider/client/TaskContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class TaskContext {
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params, TaskIo... Inputs>
auto
start(TaskFunction<ReturnType, Params...> const& task, Inputs&&... inputs) -> Job<ReturnType> {
auto start(TaskFunction<ReturnType, Params...> const& task, Inputs&&... inputs)
-> Job<ReturnType> {
// Check input type
static_assert(
sizeof...(Inputs) == sizeof...(Params),
Expand Down Expand Up @@ -187,8 +187,8 @@ class TaskContext {
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params, TaskIo... Inputs>
auto
start(TaskGraph<ReturnType, Params...> const& graph, Inputs&&... inputs) -> Job<ReturnType> {
auto start(TaskGraph<ReturnType, Params...> const& graph, Inputs&&... inputs)
-> Job<ReturnType> {
// Check input type
static_assert(
sizeof...(Inputs) == sizeof...(Params),
Expand Down
2 changes: 0 additions & 2 deletions src/spider/client/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "type_utils.hpp"

namespace spider {

/**
* Concept that represents the input to or output from a Task.
*
Expand Down Expand Up @@ -92,7 +91,6 @@ struct MergeTaskGraphTypes<TaskGraph<ReturnType, GraphParams...>, InputType, Inp

template <TaskIo ReturnType, RunnableOrTaskIo... Inputs>
using TaskGraphType = typename MergeTaskGraphTypes<TaskGraph<ReturnType>, Inputs...>::Type;

} // namespace spider

#endif // SPIDER_CLIENT_TASK_HPP
1 change: 0 additions & 1 deletion src/spider/client/type_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ struct ExtractTemplateParam<t<P>> {

template <class T>
using ExtractTemplateParamT = typename ExtractTemplateParam<T>::Type;

} // namespace spider
#endif // SPIDER_CLIENT_TYPE_UTILS_HPP
1 change: 0 additions & 1 deletion src/spider/core/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Data {
m_id = gen();
}
};

} // namespace spider::core

#endif // SPIDER_CORE_DATA_HPP
2 changes: 0 additions & 2 deletions src/spider/core/DataImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "Data.hpp"

namespace spider::core {

class DataImpl {
public:
template <class T>
Expand All @@ -26,7 +25,6 @@ class DataImpl {
return data.get_impl();
}
};

} // namespace spider::core

#endif
2 changes: 0 additions & 2 deletions src/spider/core/Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <boost/uuid/uuid.hpp>

namespace spider::core {

class Driver {
public:
explicit Driver(boost::uuids::uuid const id) : m_id{id} {}
Expand Down Expand Up @@ -36,7 +35,6 @@ class Scheduler {
std::string m_addr;
int m_port;
};

} // namespace spider::core

#endif // SPIDER_CORE_DRIVER_HPP
1 change: 0 additions & 1 deletion src/spider/core/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct StorageErr {

[[nodiscard]] auto success() const -> bool { return StorageErrType::Success == type; }
};

} // namespace spider::core

#endif // SPIDER_CORE_ERROR_HPP
2 changes: 0 additions & 2 deletions src/spider/core/JobMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <boost/uuid/uuid.hpp>

namespace spider::core {

class JobMetadata {
public:
JobMetadata() = default;
Expand Down Expand Up @@ -41,7 +40,6 @@ enum class JobStatus : std::uint8_t {
Failed,
Cancelled
};

} // namespace spider::core

#endif // SPIDER_CORE_JOBMETADATA_HPP
19 changes: 10 additions & 9 deletions src/spider/core/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
namespace spider::core {
class TaskInput {
public:
explicit TaskInput(std::string type) : m_type(std::move(type)) {};
explicit TaskInput(std::string type) : m_type(std::move(type)) {}

TaskInput(boost::uuids::uuid output_task_id, std::uint8_t position, std::string type)
: m_task_output({output_task_id, position}),
m_type(std::move(type)) {};
m_type(std::move(type)) {}

TaskInput(std::string value, std::string type)
: m_value(std::move(value)),
m_type(std::move(type)) {};
m_type(std::move(type)) {}

explicit TaskInput(boost::uuids::uuid data_id)
: m_data_id(data_id),
m_type(typeid(spider::core::Data).name()) {};
m_type(typeid(spider::core::Data).name()) {}

[[nodiscard]] auto get_task_output(
) const -> std::optional<std::tuple<boost::uuids::uuid, std::uint8_t>> {
[[nodiscard]] auto get_task_output() const
-> std::optional<std::tuple<boost::uuids::uuid, std::uint8_t>> {
return m_task_output;
}

Expand Down Expand Up @@ -145,8 +147,8 @@ class ScheduleTaskMetadata {

auto set_client_id(boost::uuids::uuid const client_id) -> void { m_client_id = client_id; }

auto set_job_creation_time(std::chrono::system_clock::time_point const job_creation_time
) -> void {
auto set_job_creation_time(std::chrono::system_clock::time_point const job_creation_time)
-> void {
m_job_creation_time = job_creation_time;
}

Expand Down Expand Up @@ -222,7 +224,6 @@ class Task {
std::vector<TaskInput> m_inputs;
std::vector<TaskOutput> m_outputs;
};

} // namespace spider::core

#endif // SPIDER_CORE_TASK_HPP
Loading