-
Notifications
You must be signed in to change notification settings - Fork 26
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
[SCHEMATIC-183] Update tests - Use magic mock and add parentId #1554
[SCHEMATIC-183] Update tests - Use magic mock and add parentId #1554
Conversation
schematic/store/synapse.py
Outdated
# HACK: must requery the fileview to get new files, since SynapseStorage will query the last state | ||
# of the fileview which may not contain any new folders in the fileview. | ||
# This is a workaround to fileviews not always containing the latest information | ||
self.query_fileview(force_requery=True) |
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.
Post in the team channel to discuss this hack and there's a message in #synapse channel for us to chime in on
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 wonder if there is something that we can do here with this API:
https://rest-docs.synapse.org/rest/POST/entity/id/table/query/async/start.html
Specifically:
"The last updated on date of the table (lastUpdatedOn) = 0x80"
If this get's updated as data is indexed into the table we could fetch the lastUpdatedOn field before we query the table to know if we need to re-query the table or not.
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.
Another thing to note: if we look at the failing test that was the motivation behind this hack, it's because it falls outside of the overall schematic flow.
So for example: when people upload a bunch of files, they usually first run manifest generate. Now manifest generate will have a "this dataset doesn't exist" situation but then afterwards, the fileview should always consist of the data - theoretically. There have been incidents when it doesn't but that's very little in the grand scheme of things.
So we could remove the hack and trigger the fileview indexing within the test but that's probably best as a team decision (but that probably complicates things a bit as it requires re-querying within the synapse storage context that is being passed along per testing function)
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.
@GiaJordan After a team discussion, we decided that it would be better to modify the test to re-query the fileview since this is such an edgecase. It does throw an error already, and upon multiple runs of this code outside of the test, it would work. This only doesn't work so smoothly in the test because resources are created and destroyed.
FAILED tests/integration/test_metadata_model.py::TestMetadataModel::test_submit_filebased_manifest_file_and_entities_valid_manifest_submitted - LookupError: Dataset syn64313762 could not be found in fileview syn23643253.
FAILED tests/integration/test_metadata_model.py::TestMetadataModel::test_submit_filebased_manifest_file_and_entities_mock_filename - LookupError: Dataset syn64313765 could not be found in fileview syn23643253.
I commented out the HACK for now and the CI will run and I updated the HACK into the test: b8360cb
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.
@thomasyu888 thanks for the information and the update!
@@ -705,7 +705,10 @@ def getFilesInStorageDataset( | |||
ValueError: Dataset ID not found. | |||
""" | |||
file_list = [] |
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.
Work with Bryan to see the difference in speeds between dev branch and prod branch within signoz.
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.
Is necessary to filter out difference between branches in gh runs. It's possible to get the data now, just a bit more difficult to filter it out. As of now the average duration of this function plotted over time:
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.
Feel free to pull develop into this feature branch and we can compare the develop branch to this feature branch performance.
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.
Thanks @BryanFauble. Done
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.
@thomasyu888 These are the results over the past 5 days. We can see your branch has a much better average execution time for this function. Although, similar to bwmac/SCHEMATIC-163/error-message-update
for some reason.
We can selected on a few fields to filter for what we want, perform an average of the duration for the function, then group by a few fields to get these results.
@@ -400,38 +400,31 @@ def test_mock_get_files_in_storage_dataset( | |||
with patch( | |||
"schematic.store.synapse.CONFIG", return_value=TEST_CONFIG | |||
) as mock_config: | |||
with patch.object(synapse_store, "syn") as mock_synapse_client: |
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.
This is me misleading Gianna, but there are times when we want a connection with Synapse and there are times we don't.
This is probably a case where it is ok for there to a direct connection with Synapse to simplify the mocking - since you've included in your other test/test_store.py
the mocked version.
@@ -19,12 +19,10 @@ | |||
import numpy as np | |||
import pandas as pd | |||
import synapseclient | |||
import synapseutils |
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.
If you're using vscode, you may see unused imports "grayed" out. It's ok to remove them in PRs, the intent is that each PR that we contribute should put the codebase in a better place.
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.
Pylint would also catch this, but this module hasn't been gone through and fixed so that is passes, so it isn't included in the pylint check.
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 agree with the changes you've made on this so far, although, as you mention - includes some hacks.
Quality Gate passedIssues Measures |
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.
Looks good to me. Thanks Tom!
@GiaJordan feel free to merge this after you review it since I may be on a flight. Thanks everyone for their reviews! Let's make any additional changes on your branch |
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.
Thanks for the changes @thomasyu888 looks good to me!
3261dcc
into
fds-2293-file-paths-for-manifest-gen
perform_query=True
parameter when the class is instantiatedpatch.object
, but there's that weird syntax (choose your poison situation).query_fileview
is the function called to get the fileview, so you want to mock thatnotes about the hack, this is what happens before the HACK