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

Run history #885

Merged
merged 1 commit into from
Sep 14, 2017
Merged

Run history #885

merged 1 commit into from
Sep 14, 2017

Conversation

csordasmarton
Copy link
Contributor

@csordasmarton csordasmarton commented Sep 7, 2017

Closes #783

@csordasmarton csordasmarton added enhancement 🌟 API change 📄 Content of patch changes API! database 🗄️ Issues related to the database schema. GUI 🎨 WARN ⚠️: Backward compatibility breaker! MIND THE GAP! Merging this patch will mess up compatibility with the previous releases! labels Sep 7, 2017
@csordasmarton csordasmarton added this to the 6.0 pre4 milestone Sep 7, 2017
@@ -32,6 +32,13 @@ struct RunData {
}
typedef list<RunData> RunDataList

struct RunHistoryData {
1: string tag, // tag of the report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet again, format the comments here as a full string, and below, etc.

@@ -188,6 +197,9 @@ service codeCheckerDBAccess {
throws (1: shared.RequestFailed requestError),

// PERMISSION: PRODUCT_ACCESS
RunHistoryDataList getRunHistory(1: i64 runId)
throws (1: shared.RequestFailed requestError),

ReportData getReport(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment line for what permission is needed to getReport() went missing as the new function was introduced above.

dest="tag",
required=False,
default=argparse.SUPPRESS,
help="Tag which identifies a certain run update.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay... there are a lot of concepts not really explained here. "Update"? "Tag"? I think this help message should be made better...

I believe An identifier for this individual store of results in the run's history. (Run history is used on the GUI.)

@@ -107,6 +107,13 @@ def add_arguments_to_parser(parser):
"the '--name' parameter given to 'codechecker-"
"analyze' will be used, if exists.")

parser.add_argument('--tag',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new argument is added, but the documentation for the store command was not updated.

ForeignKey('runs.id', deferrable=True,
initially="DEFERRED", ondelete='CASCADE'),
index=True)
tag = Column(String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tags need not be unique then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it would be unique, how would I add the same tag for the same or for a different run?
E.g:

run_id tag user date
1 v1.0 Anonymous 2017-09-06 16:56:33.681858
1 v1.0 Anonymous 2017-09-06 17:56:33.681858

The question is, do we want to allow the user to do this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ask the others. @dkrupp @gyorb Depends on whether we want to consider this annotation as a tag or as a comment. Tags, such as version tags, are usually unique.

Copy link
Member

@dkrupp dkrupp Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tag should be unique at least within a run, because it should "uniquely" identify a single update within a run. most probably users will use it to identify the version of software they are analyzing (e.g. the git hash).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name using the name version tag would be more obvious.

@@ -198,6 +217,9 @@ class Report(Base):
'reopened',
name='detection_status'))

detected_at = Column(DateTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a NOT NULL constraint should exist on the detected_at column? Every report is expected to have at least a detection date.

@@ -11,6 +11,7 @@
import codecs
from collections import defaultdict
import datetime
from datetime import timedelta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only use timedelta at one place, I'd rather not have a separate import just for this.


if report_filter.fixedDate:
date = datetime.strptime(report_filter.fixedDate, '%Y-%m-%d')
tomorrow = date + timedelta(days=1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use datetime.timedelta() if it is possible. At other places, datetime.strfptime() is used in a similar manner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm using this way I'm getting the following error:

type object 'datetime.datetime' has no attribute 'timedelta'

I used the following import to resolve this problem:

from datetime import datetime, timedelta

@@ -527,6 +553,36 @@ def getRunData(self, run_name_filter):
session.close()

@timeit
def getRunHistory(self, run_id):
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only users who have access to the product should be able to query run history.

self.__require_access()

, before the try statement.

@@ -2300,10 +2357,15 @@ def massStoreRun(self, name, version, b64zip, force):
file_content,
None)

user = self.__auth_session.user \
if self.__auth_session else "Anonymous"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Anonymous'

@@ -94,7 +101,9 @@ struct ReportFilter_v2 {
4: list<string> reportHash,
5: list<shared.Severity> severity,
6: list<shared.ReviewStatus> reviewStatus,
7: list<shared.DetectionStatus> detectionStatus
7: list<shared.DetectionStatus> detectionStatus,
8: optional string detectedDate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to store something like an ID to the run in the history where it was first detected/fixed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since CodeChecker 6, a run ID is a very, very long running stable variable. A run is only introduced once and then for the entire lifespan of the project, it is not expected to be deleted, only updated (stored into) later on. Storing does not change the run ID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I would like it better if dates would be sent as at least integers (in epoch time), not strings, and let the client do the formatting of these values (perhaps different clients with region-specific formats?)

Copy link
Contributor

@Xazax-hun Xazax-hun Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not mean the run ID, but an ID to an entry in the run history table. So we can actually check who executed the run and what was the actual tag without joining on the date which is very error prone.

@csordasmarton csordasmarton force-pushed the run_history branch 2 times, most recently from b65a0eb to 754086d Compare September 7, 2017 14:31
@csordasmarton
Copy link
Contributor Author

I also did some minor changes: in case of the enum-based filters (severity, review status), I encoded the string value (instead of the enum value) into the URL.

http://localhost:8001/Default/#run=2&detection-status=resolved&severity=high

Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

travis test fails with all databases please check why.

@csordasmarton
Copy link
Contributor Author

All travis test cases are successfully passed.

Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure that version tag is unique within a run.

@csordasmarton csordasmarton force-pushed the run_history branch 2 times, most recently from bbd66ff to 3c04a73 Compare September 8, 2017 15:33
@csordasmarton csordasmarton added the WIP 💣 Work In Progress label Sep 8, 2017
@csordasmarton csordasmarton force-pushed the run_history branch 9 times, most recently from d45021d to b5ed4f2 Compare September 12, 2017 13:01
@@ -25,6 +25,22 @@ struct RunData {
}
typedef list<RunData> RunDataList

struct RunHistoryData {
1: i64 runId, // Unique id of the run.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to return the runId the client calls the api with a runId getRunHistory(1: i64 runId)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need it, because we can call the getRunHistory function without run id. In this case we get back history data for all runs. (See Run history tab under All reports).

struct RunHistoryData {
1: i64 runId, // Unique id of the run.
2: string runName, // Name of the run.
3: string tag, // Tag of the report.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the tag of the run?
Will we support only one tag for each history data entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • A version tag is uniquely identifying a store. Actually, the last tag at the run history data is the tag of the run.
  • We support only one tag for each history data as I know.

7: list<shared.DetectionStatus> detectionStatus
7: list<shared.DetectionStatus> detectionStatus,
8: list<string> runHistoryTag,
9: optional string detectedDate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think detectionDate or firstDetectionDate would be more expressive. A comment would be nice that this value is set only once.

7: list<shared.DetectionStatus> detectionStatus,
8: list<string> runHistoryTag,
9: optional string detectedDate,
10: optional string fixedDate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about fixDate? I think we should comment here that this date can change.

@@ -668,6 +668,8 @@ optional arguments:
reports to the database. If not specified, the '--
name' parameter given to 'codechecker-analyze' will be
used, if exists.
--tag TAG An identifier for this individual store of results in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more descriptive help message would be better to note to the user that an already used tag can not be used again.

@@ -49,6 +50,7 @@ class CountFilter:
SEVERITY = 3
REVIEW_STATUS = 4
DETECTION_STATUS = 5
RUN_HISTORY_TAG = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 6.

ForeignKey('runs.id', deferrable=True,
initially="DEFERRED", ondelete='CASCADE'),
index=True)
tag = Column(String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name using the name version tag would be more obvious.

Copy link
Contributor

@gyorb gyorb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API call error: massStoreRun RequestFailed(errorCode=2, _message="(sqlite3.IntegrityError) UNIQUE constraint failed: run_histories.run_id, run_histories.tag [SQL: u'INSERT ...

The error if the tag is already used should be better handled. Tag is already used in this run message would be much nicer.

@gyorb
Copy link
Contributor

gyorb commented Sep 13, 2017

If I check the all reports tab and I select one tag in the filters I get the number of reports but the list of reports is empty.

Going from the all reports tab and run history if I select one tagged version the run id will be shown as the run name and the run counts will show wrong numbers.

@gyorb
Copy link
Contributor

gyorb commented Sep 13, 2017

Products page is not shown correctly, I'm not sure because of the changes here.

@gyorb
Copy link
Contributor

gyorb commented Sep 13, 2017

I can reproduce the product listing problem with chrome, firefox works fine for me.

@csordasmarton csordasmarton force-pushed the run_history branch 2 times, most recently from 71eb8fc to 0e43cb3 Compare September 13, 2017 14:29
@csordasmarton
Copy link
Contributor Author

  • I fixed the error message of an already existing tag for the run to this:
[14:50] - Storing analysis results for run 'tinyxml-resolved'
API call error: massStoreRun
RequestFailed(errorCode=2, _message='Tag v1.0 is already used in this run')
[14:50] - Storage failed: RequestFailed(errorCode=2, _message='Tag v1.0 is already used in this run')

@csordasmarton csordasmarton force-pushed the run_history branch 2 times, most recently from d2fb1f1 to b831eee Compare September 14, 2017 07:53
Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time on the API remains a string, then?

Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the concept behind showing Run History on the All reports pane?

font-size: 1.5em;
font-weight: bold;
color: #000;
font-family: Times, serif;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this style here intentional? We don't really use serif fonts in the GUI. Looks awkward.

@gyorb
Copy link
Contributor

gyorb commented Sep 14, 2017

After cleaning all the filter values setting the Fix date (only the day) in the Detection date filter the request to the server crashes.

@gyorb gyorb merged commit 9d43204 into Ericsson:master Sep 14, 2017
@csordasmarton csordasmarton deleted the run_history branch September 21, 2017 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change 📄 Content of patch changes API! database 🗄️ Issues related to the database schema. enhancement 🌟 GUI 🎨 WARN ⚠️: Backward compatibility breaker! MIND THE GAP! Merging this patch will mess up compatibility with the previous releases! WIP 💣 Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants