-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature: HTTP DELETE
node
#293
Conversation
* wrote basic delete method * not tested yet * wrote basic refresh * not tested yet * wrote test for refresh * but not finished yet
Merging to
|
I wrote delete before here: #255 I'll be putting that logic into this branch and much more. Then I'll delete the old branch. |
mypy says that the `logger: logging.Logger = None` this cannot be None because you said it should be `logging.Logger` but before it is initialized it would be None. Don't want to type it as `Optional` because it should always exist and it is not Optional, so just ignoring the error for now.
will add in later if needed
* wrote out logic and docstrings for `integrate_delete_node_helper` * wrote notes for future upgrades * ready to write tests for every node
* wrote out full test function for `delete_integration_node_helper` in integration_test_helper.py * cleaned up test_project.py test code > wrote a small snippet for my printing JSON preference
@InnocentBug any ideas on what is making CI unhappy? it seems to think that |
Yeah, weird one. I got it happy by upgrading trunk #301 |
click to expandSDK WarningThe warning could look a bit better if we decide to go with either material mkdocs admonitions or change the whole project to use to Google style docstrings as MKDocstrings seems to parse Google style docstrings style better.
Numpy StyleNumpy documentation way of writing a warning is like this Docstrings Code"""
Warnings
--------
After successfully deleting a node from the API, keep in mind that your local Project node in your script
may still contain outdated data as it has not been synced with the API.
To ensure you have the latest data, follow these steps:
1. Fetch the newest Project node from the API using the [`cript.API.search()`](./#cript.api.api.API.search) provided by the SDK.
1. Deserialize the retrieved data into a new Project node using the [`load_nodes_from_json`](../../utility_functions/#cript.nodes.util.load_nodes_from_json) utility function.
1. Replace your old Project node with the new one in your script for accurate and up-to-date information.
""" Documentation OutputIDE Documentation OutputMaterial MKDocs StyleHowever, we can use material mkdocs admonitions to style it up a bit and make it look better Docstrings Code"""
!!! Warning "Refresh Project Node After Deletion"
After successfully deleting a node from the API, keep in mind that your local Project node in your script
may still contain outdated data as it has not been synced with the API.
To ensure you have the latest data, follow these steps:
1. Fetch the newest Project node from the API using the [`cript.API.search()`](./#cript.api.api.API.search) provided by the SDK.
1. Deserialize the retrieved data into a new Project node using the [`load_nodes_from_json`](../../utility_functions/#cript.nodes.util.load_nodes_from_json) utility function.
1. Replace your old Project node with the new one in your script for accurate and up-to-date information.
""" Documentation OutputIDE Documentation Output |
This is a bit of a big PR. I apologize for that. This could be broken down into smaller PRs if we need, but in the interest of making our lives easy and not having merge conflicts I think we should keep it as one PR |
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.
I have some minor requests.
Plus I think coverage is failing now.
return | ||
|
||
# check that the node we want to delete first exists on the API | ||
my_node_paginator = cript_api.search( |
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.
I understand the logic.
But would it be better to just send delete
and handle the error from API if the node doesn't exist?
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.
that could streamline the process, but the only thing that we would lose from that would be that we did not prove that the node was there before we went to delete it, so if we start getting bugs we might be asking ourselves,
"is it having issues because the API can't delete the node? or is it because the node never existed on the API?"
I was thinking that writing it this way could be a bit more explicit, but removing the first search would honestly not take away much as far as I can see and would be pretty easy too.
You think remove it?
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.
I think, I would insist on getting rid of it in production code, but this is tests only and should be OK.
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.
I would honestly be happy getting rid of it too either now or in a future PR. I think both should work and be okay
Description
giving users a way to delete a nodes from the API
Changes
Wrote Delete
cript.API.delete()
methodUpdated Logger
set_log()
methodcript.API
classverbose
into a property that changes the class logger after the user sets it.ON
andOFF
easily throughout their scriptif self.verbose then log
cript.API.verbose
and the logging in general for that classUpdated Paginator Errors
Exception
toAPIError
APIError
APIError
did not have as much information and was unhelpful in debuggingUpdated Documentation
cript.API
tells users to use host ascriptapp.org
and since that was outdated, I changed it toapi.criptapp.org
Tests
integrate_delete_node_helper
Screenshots
Terminal Log:
cript.API.delete()
Successfully Deleted a NodeThis is logged to the terminal after the SDK successfully deletes a node from the API
New APIError Exception Terminal Output:
Documentation:
cript.API.delete()
Documentation:
cript.API logging
Known Issues
cript.API
but if we start putting it in more places then we'll need a refactor for it to make it cleaner and consider putting it withincript/logger.py
Notes
Integration Tests
Recommendation: I recommend running the all SDK tests locally to confirm everything I did works correctly
click to see screenshots of all tests ran locally
Checklist
CONTRIBUTORS.md
) in the pull request source branch.