-
Notifications
You must be signed in to change notification settings - Fork 2
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
docs: Add quick-start guide and example. #36
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces a new documentation file Changes
Sequence DiagramsequenceDiagram
participant User as User
participant Task as Task Function
participant Client as Spider Client
participant Cluster as Spider Cluster
User->>Task: Implement task function
User->>Task: Build shared library
User->>Client: Write client application
Client->>Cluster: Connect to cluster
Client->>Cluster: Submit task
Cluster->>Task: Execute task
Task-->>Cluster: Return result
Cluster-->>Client: Provide result
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (5)
docs/quick-start.md (5)
21-25
: Consider enhancing the requirements sectionA few suggestions to improve clarity:
- Add minimum version requirements for CMake
- Consider adding approximate disk space requirements for Docker images
- Format the Docker link reference to be consistent with the text (i.e., use
[Docker]
in line 23)
71-71
: Replace hard tab with spacesThe line contains a hard tab character. For consistency, use spaces for indentation.
- return x + y; + return x + y;🧰 Tools
🪛 Markdownlint (0.37.0)
71-71: Column: 1
Hard tabs(MD010, no-hard-tabs)
29-34
: Consider expanding on TaskContext usageWhile the note mentions that TaskContext will be explained later, it would be helpful to provide a brief description of its purpose here, as it's a required parameter for all tasks.
254-266
: Add execution verification stepsConsider adding:
- Expected output for successful execution
- Common error messages and their resolution
- How to verify the task was executed on the cluster
267-271
: Enhance the next steps sectionConsider adding:
- Links to advanced topics (even if the pages don't exist yet)
- Brief overview of what fault tolerance means in Spider
- Examples of more complex tasks users might want to try
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~165-~165: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
71-71: Column: 1
Hard tabs
(MD010, no-hard-tabs)
46-46: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
101-101: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
docs/quick-start.md
Outdated
# Building the task into a shared library | ||
|
||
In order for Spider to run a task, the task needs to be compiled into a shared library that Spider | ||
can load. | ||
|
||
TODO: Instructions and an example showing how to compile tasks into a shared library. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Add missing build instructions
The TODO marker indicates missing instructions for compiling tasks into a shared library. This is a blocking issue as users cannot proceed without these instructions. Consider adding:
- CMake configuration examples
- Compiler flags for shared library creation
- Output location expectations
Would you like me to help draft the missing build instructions section?
docs/quick-start.md
Outdated
switch (job_status) { | ||
case JobStatus::Succeeded: { | ||
auto result = job_status.get_result(); | ||
if (result == job_status.get_result()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the result comparison logic
The condition is comparing the result with itself, which will always be true:
if (result == job_status.get_result())
Should be:
-if (result == job_status.get_result())
+if (result == 5) // Expected sum of 2 + 3
docs/quick-start.md
Outdated
# Building the client | ||
|
||
The client can be compiled like any normal C++ application except that we need to link it to the | ||
Spider client library. | ||
|
||
TODO: Instructions and an example for how to compile the client application. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Add missing client build instructions
The TODO marker indicates missing instructions for compiling the client application. This is a blocking issue as users cannot proceed without these instructions. Consider adding:
- CMake configuration examples
- Required Spider library linking flags
- Build system requirements
Would you like me to help draft the missing client build instructions section?
🧰 Tools
🪛 LanguageTool
[uncategorized] ~165-~165: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...
(AI_HYDRA_LEO_MISSING_COMMA)
--env MARIADB_USER=spider \ | ||
--env MARIADB_PASSWORD=password \ | ||
--env MARIADB_DATABASE=spider-storage \ | ||
--env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=true \ | ||
--publish 3306:3306 mariadb:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add security warning for credentials
The example uses hardcoded credentials in plain text. Consider adding a security note about:
- Using environment variables for credentials
- Implementing proper authentication in production
- Using secure password practices
docs/quick-start.md
Outdated
To start the scheduler, run: | ||
|
||
```shell | ||
build/src/spider/spider_schdeuler \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in scheduler command
There's a typo in the executable name.
-build/src/spider/spider_schdeuler \
+build/src/spider/spider_scheduler \
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
build/src/spider/spider_schdeuler \ | |
build/src/spider/spider_scheduler \ |
docs/quick-start.md
Outdated
std::cerr << "`sum` returned unexpected result. Expected: 5. Actual: " << result | ||
<< '\n'. | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in error message
There's an invalid period after the string concatenation.
- << '\n'.
+ << '\n';
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
std::cerr << "`sum` returned unexpected result. Expected: 5. Actual: " << result | |
<< '\n'. | |
return 1; | |
std::cerr << "`sum` returned unexpected result. Expected: 5. Actual: " << result | |
<< '\n'; | |
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (4)
docs/quick-start.md (4)
157-157
:⚠️ Potential issueFix the result comparison logic
The condition is comparing the result with itself, which will always be true.
-if (result == job_status.get_result()) +if (result == 5) // Expected sum of 2 + 3
160-162
:⚠️ Potential issueFix syntax error in error message
There's an invalid period after the string concatenation.
- << '\n'. + << '\n';
231-235
:⚠️ Potential issueAdd security warning for credentials
The example uses hardcoded credentials in plain text. Consider adding a security note about:
- Using environment variables for credentials
- Implementing proper authentication in production
- Using secure password practices
257-257
:⚠️ Potential issueFix typo in scheduler command
There's a typo in the executable name.
-build/src/spider/spider_schdeuler \ +build/src/spider/spider_scheduler \
🧹 Nitpick comments (4)
docs/quick-start.md (4)
29-29
: Fix grammatical errorAdd the missing article "a":
-In Spider, a task is C++ function that satisfies the following conditions: +In Spider, a task is a C++ function that satisfies the following conditions:🧰 Tools
🪛 LanguageTool
[uncategorized] ~29-~29: Possible missing article found.
Context: ... # Writing a task In Spider, a task is C++ function that satisfies the following...(AI_HYDRA_LEO_MISSING_A)
71-71
: Replace hard tabs with spacesReplace the hard tab with spaces to maintain consistent formatting throughout the document.
🧰 Tools
🪛 Markdownlint (0.37.0)
71-71: Column: 1
Hard tabs(MD010, no-hard-tabs)
46-122
: Use proper heading structure for file namesInstead of using emphasis (_) for file names, consider using a proper heading structure:
-_tasks.hpp_ +### tasks.hpp -_tasks.cpp_ +### tasks.cpp -_client.cpp_ +### client.cpp🧰 Tools
🪛 Markdownlint (0.37.0)
71-71: Column: 1
Hard tabs(MD010, no-hard-tabs)
46-46: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
62-62: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
122-122: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
186-186
: Add missing commas for better readabilityAdd commas in the following sentences:
-The client can be compiled like any normal C++ application except that we need to link it to the Spider client library. +The client can be compiled like any normal C++ application, except that we need to link it to the Spider client library. -In future guides, we'll explain how to write more complex tasks as well as how to leverage Spider's support for fault tolerance. +In future guides, we'll explain how to write more complex tasks, as well as how to leverage Spider's support for fault tolerance.Also applies to: 311-311
🧰 Tools
🪛 LanguageTool
[uncategorized] ~186-~186: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...(AI_HYDRA_LEO_MISSING_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~29-~29: Possible missing article found.
Context: ... # Writing a task In Spider, a task is C++ function that satisfies the following...
(AI_HYDRA_LEO_MISSING_A)
[uncategorized] ~186-~186: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~311-~311: Possible missing comma found.
Context: ...we'll explain how to write more complex tasks as well as how to leverage Spider's sup...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
71-71: Column: 1
Hard tabs
(MD010, no-hard-tabs)
46-46: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
122-122: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/quick-start.md (1)
269-269
: Fix typo in documentationThere's a typographical error in the word "ihn".
- `storage_url` argument ihn the command. + `storage_url` argument in the command.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
docs/quick-start.md
46-46: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
122-122: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🔇 Additional comments (2)
docs/quick-start.md (2)
160-160
: Fix the result comparison logic
The condition is comparing job_status.get_result()
with itself instead of the expected result.
Apply this diff to fix the comparison:
-if (expected == job_status.get_result()) {
+if (result == expected) {
234-238
: Add security warning about credential handling
The examples use hardcoded credentials in plain text. This could lead to security issues if copied directly to production environments.
Consider adding a security note about:
- Using environment variables for credentials
- Implementing proper authentication in production
- Using secure password practices
Also applies to: 262-262, 286-286, 304-304
docs/quick-start.md
Outdated
Suppose that spider is added in subdirectory `spider`, we can set up the following `CMakeLists.txt` | ||
to build the task library: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add instructions for obtaining the Spider library
The guide assumes Spider is available in a subdirectory but doesn't explain how to obtain it. Consider adding instructions for:
- Cloning the Spider repository
- Setting up the library as a submodule
- Alternative installation methods
Would you like me to help draft these additional setup instructions?
Also applies to: 192-193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
docs/quick-start.md (5)
21-23
: Consider adding version requirementsWhile the requirements section lists the necessary tools, it would be helpful to specify minimum version requirements for CMake and Docker.
Would you like me to help draft the version requirements section?
31-33
: Enhance TaskContext parameter documentationWhile there's a note about explaining TaskContext later, it would be helpful to provide a brief description of its purpose here, as it's a required parameter for all tasks.
Would you like me to help draft a brief TaskContext description?
169-170
: Enhance error message clarityConsider providing more descriptive error messages that include:
- The specific operation that failed
- Any relevant context (e.g., task name, parameters)
- std::cerr << "Job failed in function " << error_and_fn_name.second << " - " - << error_and_fn_name.first << '\n'; + std::cerr << "Task execution failed: " << error_and_fn_name.first + << "\nFunction: " << error_and_fn_name.second + << "\nParameters: x=" << x << ", y=" << y << '\n';
200-205
: Specify the client executable locationAdd a note about where to find the compiled client executable in the build directory.
293-297
: Add example outputConsider adding example output showing:
- Successful execution
- Common error scenarios
This would help users verify their setup is working correctly.Would you like me to help draft the example outputs section?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~37-~37: Possible missing comma found.
Context: ... the TaskContext, Serializable, or Data types as we'll > explain them in later sectio...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~188-~188: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
46-46: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
121-121: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🔇 Additional comments (2)
docs/quick-start.md (2)
86-87
: Add instructions for obtaining the Spider directory
The guide assumes Spider is available in a subdirectory but doesn't explain how to obtain it.
226-230
: Add security warning for credentials
The example uses hardcoded credentials in plain text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
docs/quick-start.md (5)
22-29
: Consider adding system requirementsThe requirements section could benefit from additional information about:
- Minimum RAM requirements
- Disk space requirements
- Network requirements (ports, firewall settings)
- Supported operating systems
Would you like me to help draft these additional requirements?
40-42
: Enhance TaskContext documentationWhile the note mentions that TaskContext will be explained in other guides, consider adding a brief description or link to preliminary documentation about:
- Basic TaskContext operations
- Common use cases
- Error handling expectations
Would you like me to help draft this additional documentation?
116-121
: Enhance build instructionsConsider adding:
- Troubleshooting section for common build errors
- Platform-specific build flags
- Debug build configuration
- Installation instructions for the built library
Would you like me to help draft these additional instructions?
166-189
: Enhance error handling examplesConsider adding examples for handling:
- Network connectivity issues
- Timeout scenarios
- Task cancellation
- Resource cleanup
Would you like me to help draft these additional examples?
201-201
: Fix missing commas in sentencesAdd commas in the following sentences:
- "The client can be compiled like any normal C++ application, except that we need to link it to the Spider client library."
- "In future guides, we'll explain how to write more complex tasks, as well as how to leverage Spider's support for fault tolerance."
Also applies to: 321-321
🧰 Tools
🪛 LanguageTool
[uncategorized] ~201-~201: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...(AI_HYDRA_LEO_MISSING_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~50-~50: Loose punctuation mark.
Context: ... see in later sections. src/tasks.hpp
: ```c++ #include <spider/client/spider....
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~66-~66: Loose punctuation mark.
Context: ... x, int y) -> int; `src/tasks.cpp`:
c++ #include "tasks.hpp" #include ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~100-~100: Loose punctuation mark.
Context: ...to the same directory. CMakelists.txt
: ```cmake cmake_minimum_required(VERSIO...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~134-~134: Loose punctuation mark.
Context: ...d verifies its result. src/client.cpp
: ```c++ #include #include <s...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~201-~201: Possible missing comma found.
Context: ...ent can be compiled like any normal C++ application except that we need to link it to the S...
(AI_HYDRA_LEO_MISSING_COMMA)
[style] ~302-~302: Using many exclamation marks might seem excessive (in this case: 7 exclamation marks for a text that’s 4969 characters long)
Context: ...orage_url` argument in the command. > [!TIP] > You can start multiple workers to...
(EN_EXCESSIVE_EXCLAMATION)
[uncategorized] ~321-~321: Possible missing comma found.
Context: ...we'll explain how to write more complex tasks as well as how to leverage Spider's sup...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
248-248: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
> [!WARNING] | ||
> When the container above is stopped, the database will be deleted. In production, you should set | ||
> up a database instance with some form of data persistence. | ||
|
||
> [!WARNING] | ||
> The container above is using hardcoded default credentials that shouldn't be used in production. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance security considerations
While the warnings about credentials and data persistence are good, consider adding:
- Instructions for secure credential management
- Network security recommendations
- Access control best practices
- SSL/TLS configuration guidelines
Would you like me to help draft these security guidelines?
🧰 Tools
🪛 Markdownlint (0.37.0)
248-248: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (5)
docs/quick-start.md (5)
22-29
: Add supported platforms informationConsider adding information about supported operating systems and architectures to help users determine if their environment is compatible.
116-121
: Add build troubleshooting sectionConsider adding a troubleshooting section that covers:
- Common build errors and their solutions
- Platform-specific build considerations
- Required environment variables
214-217
: Add debug build instructionsConsider adding instructions for:
- Building in debug mode
- Enabling logging
- Using debug symbols
219-227
: Add production deployment guidelinesConsider adding a section about:
- High availability setup
- Load balancing configuration
- Monitoring and logging
- Backup strategies
308-318
: Add verification stepsConsider adding:
- Expected output examples
- Success/failure indicators
- Troubleshooting steps for common issues
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~50-~50: Loose punctuation mark.
Context: ... see in later sections. src/tasks.hpp
: ```c++ #include <spider/client/spider....
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~66-~66: Loose punctuation mark.
Context: ... x, int y) -> int; `src/tasks.cpp`:
c++ #include "tasks.hpp" #include ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~100-~100: Loose punctuation mark.
Context: ...to the same directory. CMakelists.txt
: ```cmake cmake_minimum_required(VERSIO...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~134-~134: Loose punctuation mark.
Context: ...d verifies its result. src/client.cpp
: ```c++ #include #include <s...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~302-~302: Using many exclamation marks might seem excessive (in this case: 7 exclamation marks for a text that’s 4971 characters long)
Context: ...orage_url` argument in the command. > [!TIP] > You can start multiple workers to...
(EN_EXCESSIVE_EXCLAMATION)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
248-248: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
🔇 Additional comments (2)
docs/quick-start.md (2)
90-97
: Add instructions for obtaining Spider
The guide assumes Spider is available in a subdirectory but doesn't explain how to obtain it. Consider adding:
- Git clone command for the Spider repository
- Version/branch requirements
- Alternative installation methods
238-242
: Enhance security considerations
The example uses hardcoded credentials. Consider adding:
- Instructions for secure credential management
- Environment variable usage examples
- Production security best practices
In Spider, a task is a C++ function that satisfies the following conditions: | ||
|
||
* It is a non-member function. | ||
* It takes one or more parameters: | ||
* The first parameter must be a `TaskContext`. | ||
* All other parameters must have types that conform to the `Serializable` or `Data` interfaces. | ||
* It returns a value that conforms to the `Serializable` or `Data` interfaces. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Document task error handling
Consider adding information about:
- How tasks should handle errors
- Exception handling expectations
- Error propagation to the client
docs/quick-start.md
Outdated
auto job_status = job.get_status(); | ||
switch (job_status) { | ||
case JobStatus::Succeeded: { | ||
auto result = job_status.get_result(); | ||
int expected = x + y; | ||
if (expected == result) { | ||
return 0; | ||
} else { | ||
std::cerr << "`sum` returned unexpected result. Expected: " << expected | ||
<< ". Actual: " << result << '\n'; | ||
return 1; | ||
} | ||
} | ||
case JobStatus::Failed: | ||
std::pair<std::string, std::string> error_and_fn_name = job.get_error(); | ||
std::cerr << "Job failed in function " << error_and_fn_name.second << " - " | ||
<< error_and_fn_name.first << '\n'; | ||
return 1; | ||
default: | ||
std::cerr << "Job is in unexpected state - " << job_status << '\n'; | ||
return 1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance error handling
Consider improving the error handling:
- Add timeout handling for
wait_complete()
- Include connection error handling
- Add retry logic for transient failures
docs/quick-start.md
Outdated
if (storage_url.empty()) { | ||
std::cerr << "storage-backend-url cannot be empty." << '\n'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix missing return statement
There's a missing return statement after the error message when the storage URL is empty.
if (storage_url.empty()) {
std::cerr << "storage-backend-url cannot be empty." << '\n';
+ return 1;
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (storage_url.empty()) { | |
std::cerr << "storage-backend-url cannot be empty." << '\n'; | |
} | |
if (storage_url.empty()) { | |
std::cerr << "storage-backend-url cannot be empty." << '\n'; | |
return 1; | |
} |
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/quick-start.md (1)
164-166
: Enhance client robustnessThe
wait_complete()
call should include timeout and error handling. Consider:
- Adding a timeout parameter
- Handling connection failures
- Implementing retry logic for transient errors
Example enhancement:
- job.wait_complete(); + try { + if (!job.wait_complete(std::chrono::seconds(30))) { + std::cerr << "Job timed out after 30 seconds\n"; + return 1; + } + } catch (const spider::ConnectionError& e) { + std::cerr << "Connection error: " << e.what() << '\n'; + return 1; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/quick-start.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[uncategorized] ~50-~50: Loose punctuation mark.
Context: ... see in later sections. src/tasks.hpp
: ```c++ #include <spider/client/spider....
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~66-~66: Loose punctuation mark.
Context: ... x, int y) -> int; `src/tasks.cpp`:
c++ #include "tasks.hpp" #include ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~100-~100: Loose punctuation mark.
Context: ...to the same directory. CMakelists.txt
: ```cmake cmake_minimum_required(VERSIO...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~134-~134: Loose punctuation mark.
Context: ...d verifies its result. src/client.cpp
: ```c++ #include #include <s...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~304-~304: Using many exclamation marks might seem excessive (in this case: 7 exclamation marks for a text that’s 4973 characters long)
Context: ...orage_url` argument in the command. > [!TIP] > You can start multiple workers to...
(EN_EXCESSIVE_EXCLAMATION)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
250-250: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
🔇 Additional comments (4)
docs/quick-start.md (4)
32-39
: Document error handling expectations
The task interface documentation should include guidance on:
- How tasks should handle and propagate errors
- Exception handling requirements
- Error reporting best practices through TaskContext
Would you like me to help draft the error handling documentation section?
90-97
: Clarify Spider library setup process
The guide assumes the Spider project directory is available but doesn't explain how to obtain it. Please add instructions for:
- Obtaining the Spider source code (e.g., git clone command)
- Setting up Spider as a git submodule (recommended)
- Version requirements or compatibility notes
Would you like me to help draft these setup instructions?
240-244
: Enhance security configuration
The example uses hardcoded credentials in plain text. Consider:
- Using environment variables for sensitive values
- Adding instructions for secure credential management
- Documenting SSL/TLS configuration
Example using environment variables:
- --env MARIADB_USER=spider \
- --env MARIADB_PASSWORD=password \
+ --env MARIADB_USER="${SPIDER_DB_USER}" \
+ --env MARIADB_PASSWORD="${SPIDER_DB_PASSWORD}" \
247-253
: Add comprehensive security guidelines
While the warnings about credentials and data persistence are good, please add a dedicated security section covering:
- Secure credential management best practices
- Network security configuration
- Access control recommendations
- SSL/TLS setup instructions
Would you like me to help draft these security guidelines?
🧰 Tools
🪛 Markdownlint (0.37.0)
250-250: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
docs/quick-start.md
Outdated
# Add the client | ||
add_executable(client src/client.cpp) | ||
|
||
# Link the spider library to the client | ||
target_link_libraries(client PRIVATE spider::spider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link the tasks
library as well.
# Add the client | |
add_executable(client src/client.cpp) | |
# Link the spider library to the client | |
target_link_libraries(client PRIVATE spider::spider) | |
# Add the client | |
add_executable(client src/client.cpp) | |
# Link the spider library to the client | |
target_link_libraries(client PRIVATE spider::spider) | |
# Link the tasks library to the client | |
target_link_libraries(client PRIVATE tasks) |
docs/quick-start.md
Outdated
```shell | ||
cmake -S spider -B spider/build | ||
cmake --build spider/build --parallel $(nproc) --target spider_scheduler | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why build spider inside a separate build directory again? The root level CMakeLists.txt
includes add_directory(spider)
, which can be used to spider.
@sitaowang1998 Addressed your comments by moving the quick-start source code into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
examples/quick-start/src/tasks.hpp (1)
7-13
: Documentation needs parameter descriptions.While the function is documented, the parameter descriptions are missing. Please add descriptions for each parameter:
/** - * @param context - * @param x - * @param y + * @param context The Spider task context + * @param x First integer to add + * @param y Second integer to add * @return The sum of x and y. */examples/quick-start/src/client.cpp (2)
24-26
: Consider using named constants for test values.Replace magic numbers with named constants to improve readability:
+ // Test values for the sum operation + constexpr int kFirstNumber = 2; + constexpr int kSecondNumber = 3; - int x = 2; - int y = 3; + int x = kFirstNumber; + int y = kSecondNumber; spider::Job<int> job = driver.start(&sum, x, y);
45-48
: Enhance error message with more details.The error message could be more informative by including the input values that caused the failure:
std::pair<std::string, std::string> error_and_fn_name = job.get_error(); - std::cerr << "Job failed in function " << error_and_fn_name.second << " - " - << error_and_fn_name.first << '\n'; + std::cerr << "Job failed in function " << error_and_fn_name.second + << " with inputs x=" << x << ", y=" << y << " - " + << error_and_fn_name.first << '\n';docs/quick-start.md (2)
184-196
: Add example output for successful execution.Consider adding example output showing:
- What users should expect to see when the client runs successfully
- Common error messages and their solutions
197-203
: Expand the Next Steps section.Consider adding:
- A brief list of specific topics to be covered in future guides
- Prerequisites for those advanced topics
- Estimated timeline for the release of future guides
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/quick-start.md
(1 hunks)examples/quick-start/CMakeLists.txt
(1 hunks)examples/quick-start/src/client.cpp
(1 hunks)examples/quick-start/src/tasks.cpp
(1 hunks)examples/quick-start/src/tasks.hpp
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/quick-start.md
[style] ~180-~180: Using many exclamation marks might seem excessive (in this case: 7 exclamation marks for a text that’s 4778 characters long)
Context: ...orage_url` argument in the command. > [!TIP] > You can start multiple workers to...
(EN_EXCESSIVE_EXCLAMATION)
🪛 Markdownlint (0.37.0)
docs/quick-start.md
128-128: null
Blank line inside blockquote
(MD028, no-blanks-blockquote)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: non-storage-unit-tests
- GitHub Check: lint
🔇 Additional comments (7)
examples/quick-start/src/tasks.cpp (2)
6-8
: Well-structured task implementation!The task function is concise and demonstrates the basic pattern for Spider task implementation. The trailing return type syntax aligns with modern C++ practices.
10-11
: Task registration looks good!Proper use of the SPIDER_REGISTER_TASK macro to register the task with the framework.
examples/quick-start/CMakeLists.txt (1)
1-17
: CMake configuration follows best practices!The configuration properly sets up the project structure with appropriate visibility modifiers and dependency management.
docs/quick-start.md (4)
1-31
: LGTM! Clear and well-structured introduction.The introduction effectively outlines Spider's purpose and requirements. The note about relative paths is particularly helpful for avoiding confusion.
34-41
: Document task error handling guidelines.Consider adding information about:
- How tasks should handle exceptions
- Error propagation mechanisms
- Best practices for error reporting
57-98
: LGTM! Clear build instructions provided.The build instructions for both the task library and client are well-documented and follow CMake best practices.
125-131
: Enhance security considerations documentation.While the current warnings about credentials and data persistence are good, consider adding:
- Instructions for secure credential management
- Network security recommendations
- Access control best practices
- SSL/TLS configuration guidelines
🧰 Tools
🪛 Markdownlint (0.37.0)
128-128: null
Blank line inside blockquote(MD028, no-blanks-blockquote)
// Create a driver that connects to the Spider cluster | ||
spider::Driver driver{storage_url}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling for driver initialization.
The Spider driver initialization might throw exceptions. Consider wrapping it in a try-catch block:
// Create a driver that connects to the Spider cluster
+ try {
spider::Driver driver{storage_url};
+ } catch (const std::exception& e) {
+ std::cerr << "Failed to initialize Spider driver: " << e.what() << '\n';
+ return 1;
+ }
Committable suggestion skipped: line range outside the PR's diff.
Open new pr #46 to solve the cmake and header issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
examples/quick-start/src/client.cpp (2)
19-22
: Remove redundant empty check for storage URLThe empty check is redundant since the
argc < 2
validation would already catch this case. The string constructor would receiveargv[1]
only ifargc >= 2
.- if (storage_url.empty()) { - std::cerr << "storage-backend-url cannot be empty." << '\n'; - return 1; - }🧰 Tools
🪛 GitHub Actions: code-linting-checks
[error] 1: Code should be clang-formatted
28-29
: Consider making input values configurableFor a quick-start example, consider accepting input values as command-line arguments to make it more interactive.
🧰 Tools
🪛 GitHub Actions: code-linting-checks
[error] 1: Code should be clang-formatted
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
examples/quick-start/CMakeLists.txt
(1 hunks)examples/quick-start/src/client.cpp
(1 hunks)examples/quick-start/src/tasks.cpp
(1 hunks)lint-tasks.yaml
(7 hunks)src/spider/client/Job.hpp
(1 hunks)taskfile.yaml
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- examples/quick-start/src/tasks.cpp
- examples/quick-start/CMakeLists.txt
🧰 Additional context used
🪛 GitHub Actions: code-linting-checks
examples/quick-start/src/client.cpp
[error] 1: Code should be clang-formatted
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: non-storage-unit-tests
- GitHub Check: lint
🔇 Additional comments (9)
src/spider/client/Job.hpp (1)
263-265
: Verify Impact on Client CodeLet's check for any existing usage of the
get_error()
method to assess the impact of this change.examples/quick-start/src/client.cpp (2)
24-25
: Add error handling for driver initializationThe Spider driver initialization might throw exceptions. Consider wrapping it in a try-catch block.
🧰 Tools
🪛 GitHub Actions: code-linting-checks
[error] 1: Code should be clang-formatted
35-58
: Well-structured error handling!The job status handling is comprehensive and follows best practices with clear error messages and proper handling of all cases.
🧰 Tools
🪛 GitHub Actions: code-linting-checks
[error] 1: Code should be clang-formatted
taskfile.yaml (3)
15-20
: Well-structured variable definitionsThe new variables follow the established naming conventions and maintain consistency with the existing structure.
32-40
: Good integration of examples into the build systemThe CMake configuration properly handles the new examples directory with appropriate source tracking and separate build configuration.
46-48
: Proper initialization of build directoriesThe init task correctly sets up the required directory structure.
lint-tasks.yaml (3)
51-53
: Good coverage of example directory filesThe source patterns properly include all C++ file types from the examples directory.
122-129
: Well-configured static analysis for examplesThe clang-tidy task is properly configured with the correct compile commands database for the examples directory.
68-75
: Address the clang-format pipeline failureThe formatting task is properly configured, but the pipeline indicates that some files need formatting. Please run:
auto get_error() -> std::pair<std::string, std::string> { | ||
throw ConnectionException{"Not implemented"}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add Documentation for Unimplemented Status
If the method must remain unimplemented temporarily, please add documentation explaining:
- Why the method is not implemented
- When it will be implemented
- What clients should do in the meantime
Here's a suggested documentation update:
+ /**
+ * NOTE: This method is temporarily unimplemented.
+ * TODO(SPIDER-XXX): Implement error retrieval functionality
+ * For now, clients should use get_status() to check for failure state.
+ */
auto get_error() -> std::pair<std::string, std::string> {
throw ConnectionException{"Not implemented"};
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
auto get_error() -> std::pair<std::string, std::string> { | |
throw ConnectionException{"Not implemented"}; | |
} | |
/** | |
* NOTE: This method is temporarily unimplemented. | |
* TODO(SPIDER-XXX): Implement error retrieval functionality | |
* For now, clients should use get_status() to check for failure state. | |
*/ | |
auto get_error() -> std::pair<std::string, std::string> { | |
throw ConnectionException{"Not implemented"}; | |
} |
Breaking Change: get_error
Implementation Needs Attention
This change introduces a breaking modification by throwing a ConnectionException
instead of implementing the expected error retrieval functionality. This could impact client applications that rely on error handling.
Consider these alternatives:
- Maintain backward compatibility by implementing proper error retrieval
- Mark the method as deprecated if it's being phased out
- Document the rationale for not implementing this method
Here's a suggested implementation that maintains the expected behaviour:
- auto get_error() -> std::pair<std::string, std::string> {
- throw ConnectionException{"Not implemented"};
- }
+ auto get_error() -> std::pair<std::string, std::string> {
+ std::string task_name;
+ std::string error_message;
+ core::StorageErr err = m_metadata_storage->get_job_error(m_id, &task_name, &error_message);
+ if (!err.success()) {
+ throw ConnectionException{
+ fmt::format("Failed to get job error: {}", err.description)
+ };
+ }
+ return {task_name, error_message};
+ }
Committable suggestion skipped: line range outside the PR's diff.
// Submit the task for execution | ||
int const x = 2; | ||
int const y = 3; | ||
spider::Job<int> job = driver.start(&sum, x, y); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for job submission
The start
method could throw exceptions. Consider wrapping it in a try-catch block:
// Submit the task for execution
int const x = 2;
int const y = 3;
+ spider::Job<int> job;
+ try {
job = driver.start(&sum, x, y);
+ } catch (const std::exception& e) {
+ std::cerr << "Failed to submit job: " << e.what() << '\n';
+ return 1;
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Submit the task for execution | |
int const x = 2; | |
int const y = 3; | |
spider::Job<int> job = driver.start(&sum, x, y); | |
// Submit the task for execution | |
int const x = 2; | |
int const y = 3; | |
spider::Job<int> job; | |
try { | |
job = driver.start(&sum, x, y); | |
} catch (const std::exception& e) { | |
std::cerr << "Failed to submit job: " << e.what() << '\n'; | |
return 1; | |
} |
🧰 Tools
🪛 GitHub Actions: code-linting-checks
[error] 1: Code should be clang-formatted
@coderabbitai review |
✅ Actions performedReview triggered.
|
Description
This PR adds a quick-start guide for writing a basic task and running it on Spider. In future PRs, we will explain how to write complex tasks (e.g., tasks joined together into task graph) as well as how to use Spider's data and key-value stores.
NOTE: This should not be merged until the scheduler and worker can be run as standalone processes.
Validation performed
Summary by CodeRabbit
Summary by CodeRabbit
sum
, for calculating the sum of two integers within the Spider framework.