{"action":"created","comment":{"url":"https://api.github.com/repos/9livesdata/whylog/pulls/comments/60124272","id":60124272,"diff_hunk":"@@ -2,42 +2,177 @@\n \n import six\n \n+from whylog.constraints.const import ConstraintType\n+from whylog.constraints.exceptions import ConstraintVerificationError, ConstructorParamsError\n+from whylog.teacher.user_intent import UserConstraintIntent\n+\n \n @six.add_metaclass(ABCMeta)\n class AbstractConstraint(object):\n+    \"\"\"\n+    :param MIN_GROUPS_COUNT: minimal groups count needed to create constraint\n+    :param MAX_GROUPS_COUNT: maximal groups count needed to create constraint\n+    \"\"\"\n+\n+    TYPE = 'undefined'\n+    MIN_GROUPS_COUNT = None\n+    MAX_GROUPS_COUNT = None\n+\n     @abstractmethod\n-    def save(self, rulebase_rule):\n-        pass\n+    def __init__(self, param_dict, groups):\n+        \"\"\"\n+        Creates constraint object.\n+\n+        For Teacher and Front use while creating user rule.\n+\n+        :param param_dict: dict of additional params of constraint\n+        :param groups: list of tuples (line_id, group_no),\n+                       where line_id and group_no is inner numeration between Front and Teacher\n+        \"\"\"\n+        param_dict_keys = param_dict.keys()\n+        correct_param_names = self.get_param_names()\n+        if not param_dict_keys == correct_param_names:\n+            raise ConstructorParamsError(correct_param_names, param_dict_keys)\n+        self.params = param_dict\n+        self.groups = groups\n+\n+    @abstractmethod\n+    def convert_to_user_constraint_intent(self):\n+        \"\"\"\n+        Converts constraint to UserConstraintIntent object.\n+\n+        For Teacher and Config use while saving constraint into Whylog knowledge base.\n+        \"\"\"\n+        return UserConstraintIntent(self.TYPE, self.groups, self.params)\n+\n+    @classmethod\n+    def get_param_names(cls):\n+        \"\"\"\n+        Returns names of constraint additional params.\n+\n+        For Front to display param names to user and then ask user for param contents.\n+        \"\"\"\n+        raise NotImplementedError(\"Subclass should implement this\")\n+\n+    @classmethod\n+    def get_groups_count(cls):\n+        \"\"\"\n+        Returns minimal and maximal count of groups needed to create constraint.\n+\n+        For Front to ask user for proper count of groups.\n+        0, 0 - no groups\n+        2, None - at least 2 groups\n+        2, 2 - exactly 2 groups\n+        \"\"\"\n+        return cls.MIN_GROUPS_COUNT, cls.MAX_GROUPS_COUNT\n+\n+    @classmethod\n+    def verify(cls, param_dict, group_contents):\n+        \"\"\"\n+        Verifies constraint for given params and groups contents.\n+\n+        For LogReader and Teacher verification.\n+        \"\"\"\n+        raise NotImplementedError(\"Subclass should implement this\")\n \n \n class TimeConstraint(AbstractConstraint):\n-    def __init__(self, line_earlier, line_later, min_delta=None, max_delta=None):\n-        pass\n+    \"\"\"\n+    Time delta between two dates must be greater than 'max_delta' and lower than 'min_delta'\n+    \"\"\"\n+\n+    TYPE = ConstraintType.TIME_DELTA\n+\n+    MIN_GROUPS_COUNT = 0\n+    MAX_GROUPS_COUNT = 0\n+\n+    GROUP_EARLIER = 'group_earlier'\n+    GROUP_LATER = 'group_later'\n+    MIN_DELTA = 'min_delta'\n+    MAX_DELTA = 'max_delta'\n+\n+    def __init__(self, param_dict, groups):\n+        \"\"\"\n+        I.e:\n+        TimeConstraint(\n+            {'group_earlier': (3, 1), 'group_later': (4, 2), 'min_delta': 12, 'max_delta' 30},\n+            list()\n+        )\n+        \"\"\"\n+        super(TimeConstraint, self).__init__(param_dict, groups)\n+\n+    def convert_to_user_constraint_intent(self):\n+        return super(TimeConstraint, self).convert_to_user_constraint_intent()\n \n+    @classmethod\n+    def get_param_names(cls):\n+        return [cls.GROUP_EARLIER, cls.GROUP_LATER, cls.MIN_DELTA, cls.MAX_DELTA]\n \n-class IdenticalIntervals(AbstractConstraint):\n-    def __init__(self, intervals):\n-        pass\n+    @classmethod\n+    def get_groups_count(cls):\n+        return super(TimeConstraint, cls).get_groups_count()\n \n+    @classmethod\n+    def verify(cls, param_dict, group_contents):\n+        #TODO\n+        raise NotImplementedError\n \n-class AnyValueIntervals(AbstractConstraint):\n-    def __init__(self, intervals):\n-        pass\n \n+class IdenticalConstraint(AbstractConstraint):\n+    \"\"\"\n+    Contents of groups must be identical.\n+    \"\"\"\n \n-class DifferentValueIntervals(AbstractConstraint):\n-    def __init__(self, intervals):\n-        pass\n+    TYPE = ConstraintType.IDENTICAL\n \n+    MIN_GROUPS_COUNT = 2\n+    MAX_GROUPS_COUNT = None\n \n-class ConstIntervals(AbstractConstraint):\n-    def __init__(self, intervals):\n-        pass\n+    def __init__(self, param_dict, groups):\n+        \"\"\"\n+        I.e:\n+        IdenticalConstraint(\n+            dict(),\n+            [(1, 2), (2, 4)]\n+        )\n+        \"\"\"\n+        super(IdenticalConstraint, self).__init__(param_dict, groups)\n+\n+    def convert_to_user_constraint_intent(self):","path":"whylog/constraints/__init__.py","position":156,"original_position":156,"commit_id":"c6d3d0634231eff79fa78030dc5736e152032c19","original_commit_id":"c6d3d0634231eff79fa78030dc5736e152032c19","user":{"login":"andrzejgorski","id":13272962,"avatar_url":"https://avatars.githubusercontent.com/u/13272962?v=3","gravatar_id":"","url":"https://api.github.com/users/andrzejgorski","html_url":"https://github.com/andrzejgorski","followers_url":"https://api.github.com/users/andrzejgorski/followers","following_url":"https://api.github.com/users/andrzejgorski/following{/other_user}","gists_url":"https://api.github.com/users/andrzejgorski/gists{/gist_id}","starred_url":"https://api.github.com/users/andrzejgorski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrzejgorski/subscriptions","organizations_url":"https://api.github.com/users/andrzejgorski/orgs","repos_url":"https://api.github.com/users/andrzejgorski/repos","events_url":"https://api.github.com/users/andrzejgorski/events{/privacy}","received_events_url":"https://api.github.com/users/andrzejgorski/received_events","type":"User","site_admin":false},"body":"I don't understand whatfor is `@classmethod` decorator in other methods. If you use it there, you should it here to be consistent.","created_at":"2016-04-18T20:03:04Z","updated_at":"2016-04-18T20:03:04Z","html_url":"https://github.com/9livesdata/whylog/pull/94#discussion_r60124272","pull_request_url":"https://api.github.com/repos/9livesdata/whylog/pulls/94","_links":{"self":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/comments/60124272"},"html":{"href":"https://github.com/9livesdata/whylog/pull/94#discussion_r60124272"},"pull_request":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/94"}}},"pull_request":{"url":"https://api.github.com/repos/9livesdata/whylog/pulls/94","id":66696082,"html_url":"https://github.com/9livesdata/whylog/pull/94","diff_url":"https://github.com/9livesdata/whylog/pull/94.diff","patch_url":"https://github.com/9livesdata/whylog/pull/94.patch","issue_url":"https://api.github.com/repos/9livesdata/whylog/issues/94","number":94,"state":"open","locked":false,"title":"Constraints","user":{"login":"epawlowska","id":15253107,"avatar_url":"https://avatars.githubusercontent.com/u/15253107?v=3","gravatar_id":"","url":"https://api.github.com/users/epawlowska","html_url":"https://github.com/epawlowska","followers_url":"https://api.github.com/users/epawlowska/followers","following_url":"https://api.github.com/users/epawlowska/following{/other_user}","gists_url":"https://api.github.com/users/epawlowska/gists{/gist_id}","starred_url":"https://api.github.com/users/epawlowska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epawlowska/subscriptions","organizations_url":"https://api.github.com/users/epawlowska/orgs","repos_url":"https://api.github.com/users/epawlowska/repos","events_url":"https://api.github.com/users/epawlowska/events{/privacy}","received_events_url":"https://api.github.com/users/epawlowska/received_events","type":"User","site_admin":false},"body":"AbstractConstraint\r\nTimeConstraint\r\nIdenticalConstraint","created_at":"2016-04-15T19:55:42Z","updated_at":"2016-04-18T20:03:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4a1c480d5cbe187f78cbcbba085a92b3da0b717","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/9livesdata/whylog/pulls/94/commits","review_comments_url":"https://api.github.com/repos/9livesdata/whylog/pulls/94/comments","review_comment_url":"https://api.github.com/repos/9livesdata/whylog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/9livesdata/whylog/issues/94/comments","statuses_url":"https://api.github.com/repos/9livesdata/whylog/statuses/c6d3d0634231eff79fa78030dc5736e152032c19","head":{"label":"epawlowska:constraints","ref":"constraints","sha":"c6d3d0634231eff79fa78030dc5736e152032c19","user":{"login":"epawlowska","id":15253107,"avatar_url":"https://avatars.githubusercontent.com/u/15253107?v=3","gravatar_id":"","url":"https://api.github.com/users/epawlowska","html_url":"https://github.com/epawlowska","followers_url":"https://api.github.com/users/epawlowska/followers","following_url":"https://api.github.com/users/epawlowska/following{/other_user}","gists_url":"https://api.github.com/users/epawlowska/gists{/gist_id}","starred_url":"https://api.github.com/users/epawlowska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epawlowska/subscriptions","organizations_url":"https://api.github.com/users/epawlowska/orgs","repos_url":"https://api.github.com/users/epawlowska/repos","events_url":"https://api.github.com/users/epawlowska/events{/privacy}","received_events_url":"https://api.github.com/users/epawlowska/received_events","type":"User","site_admin":false},"repo":{"id":46919661,"name":"whylog","full_name":"epawlowska/whylog","owner":{"login":"epawlowska","id":15253107,"avatar_url":"https://avatars.githubusercontent.com/u/15253107?v=3","gravatar_id":"","url":"https://api.github.com/users/epawlowska","html_url":"https://github.com/epawlowska","followers_url":"https://api.github.com/users/epawlowska/followers","following_url":"https://api.github.com/users/epawlowska/following{/other_user}","gists_url":"https://api.github.com/users/epawlowska/gists{/gist_id}","starred_url":"https://api.github.com/users/epawlowska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epawlowska/subscriptions","organizations_url":"https://api.github.com/users/epawlowska/orgs","repos_url":"https://api.github.com/users/epawlowska/repos","events_url":"https://api.github.com/users/epawlowska/events{/privacy}","received_events_url":"https://api.github.com/users/epawlowska/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/epawlowska/whylog","description":"","fork":true,"url":"https://api.github.com/repos/epawlowska/whylog","forks_url":"https://api.github.com/repos/epawlowska/whylog/forks","keys_url":"https://api.github.com/repos/epawlowska/whylog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/epawlowska/whylog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/epawlowska/whylog/teams","hooks_url":"https://api.github.com/repos/epawlowska/whylog/hooks","issue_events_url":"https://api.github.com/repos/epawlowska/whylog/issues/events{/number}","events_url":"https://api.github.com/repos/epawlowska/whylog/events","assignees_url":"https://api.github.com/repos/epawlowska/whylog/assignees{/user}","branches_url":"https://api.github.com/repos/epawlowska/whylog/branches{/branch}","tags_url":"https://api.github.com/repos/epawlowska/whylog/tags","blobs_url":"https://api.github.com/repos/epawlowska/whylog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/epawlowska/whylog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/epawlowska/whylog/git/refs{/sha}","trees_url":"https://api.github.com/repos/epawlowska/whylog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/epawlowska/whylog/statuses/{sha}","languages_url":"https://api.github.com/repos/epawlowska/whylog/languages","stargazers_url":"https://api.github.com/repos/epawlowska/whylog/stargazers","contributors_url":"https://api.github.com/repos/epawlowska/whylog/contributors","subscribers_url":"https://api.github.com/repos/epawlowska/whylog/subscribers","subscription_url":"https://api.github.com/repos/epawlowska/whylog/subscription","commits_url":"https://api.github.com/repos/epawlowska/whylog/commits{/sha}","git_commits_url":"https://api.github.com/repos/epawlowska/whylog/git/commits{/sha}","comments_url":"https://api.github.com/repos/epawlowska/whylog/comments{/number}","issue_comment_url":"https://api.github.com/repos/epawlowska/whylog/issues/comments{/number}","contents_url":"https://api.github.com/repos/epawlowska/whylog/contents/{+path}","compare_url":"https://api.github.com/repos/epawlowska/whylog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/epawlowska/whylog/merges","archive_url":"https://api.github.com/repos/epawlowska/whylog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/epawlowska/whylog/downloads","issues_url":"https://api.github.com/repos/epawlowska/whylog/issues{/number}","pulls_url":"https://api.github.com/repos/epawlowska/whylog/pulls{/number}","milestones_url":"https://api.github.com/repos/epawlowska/whylog/milestones{/number}","notifications_url":"https://api.github.com/repos/epawlowska/whylog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/epawlowska/whylog/labels{/name}","releases_url":"https://api.github.com/repos/epawlowska/whylog/releases{/id}","deployments_url":"https://api.github.com/repos/epawlowska/whylog/deployments","created_at":"2015-11-26T10:22:17Z","updated_at":"2016-03-01T22:57:23Z","pushed_at":"2016-04-17T18:11:48Z","git_url":"git://github.com/epawlowska/whylog.git","ssh_url":"git@github.com:epawlowska/whylog.git","clone_url":"https://github.com/epawlowska/whylog.git","svn_url":"https://github.com/epawlowska/whylog","homepage":null,"size":491,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"9livesdata:master","ref":"master","sha":"d907bb257031665d6d6039ec5dc445009d4c41b9","user":{"login":"9livesdata","id":15250580,"avatar_url":"https://avatars.githubusercontent.com/u/15250580?v=3","gravatar_id":"","url":"https://api.github.com/users/9livesdata","html_url":"https://github.com/9livesdata","followers_url":"https://api.github.com/users/9livesdata/followers","following_url":"https://api.github.com/users/9livesdata/following{/other_user}","gists_url":"https://api.github.com/users/9livesdata/gists{/gist_id}","starred_url":"https://api.github.com/users/9livesdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9livesdata/subscriptions","organizations_url":"https://api.github.com/users/9livesdata/orgs","repos_url":"https://api.github.com/users/9livesdata/repos","events_url":"https://api.github.com/users/9livesdata/events{/privacy}","received_events_url":"https://api.github.com/users/9livesdata/received_events","type":"Organization","site_admin":false},"repo":{"id":44754618,"name":"whylog","full_name":"9livesdata/whylog","owner":{"login":"9livesdata","id":15250580,"avatar_url":"https://avatars.githubusercontent.com/u/15250580?v=3","gravatar_id":"","url":"https://api.github.com/users/9livesdata","html_url":"https://github.com/9livesdata","followers_url":"https://api.github.com/users/9livesdata/followers","following_url":"https://api.github.com/users/9livesdata/following{/other_user}","gists_url":"https://api.github.com/users/9livesdata/gists{/gist_id}","starred_url":"https://api.github.com/users/9livesdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9livesdata/subscriptions","organizations_url":"https://api.github.com/users/9livesdata/orgs","repos_url":"https://api.github.com/users/9livesdata/repos","events_url":"https://api.github.com/users/9livesdata/events{/privacy}","received_events_url":"https://api.github.com/users/9livesdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/9livesdata/whylog","description":"","fork":false,"url":"https://api.github.com/repos/9livesdata/whylog","forks_url":"https://api.github.com/repos/9livesdata/whylog/forks","keys_url":"https://api.github.com/repos/9livesdata/whylog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/9livesdata/whylog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/9livesdata/whylog/teams","hooks_url":"https://api.github.com/repos/9livesdata/whylog/hooks","issue_events_url":"https://api.github.com/repos/9livesdata/whylog/issues/events{/number}","events_url":"https://api.github.com/repos/9livesdata/whylog/events","assignees_url":"https://api.github.com/repos/9livesdata/whylog/assignees{/user}","branches_url":"https://api.github.com/repos/9livesdata/whylog/branches{/branch}","tags_url":"https://api.github.com/repos/9livesdata/whylog/tags","blobs_url":"https://api.github.com/repos/9livesdata/whylog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/9livesdata/whylog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/9livesdata/whylog/git/refs{/sha}","trees_url":"https://api.github.com/repos/9livesdata/whylog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/9livesdata/whylog/statuses/{sha}","languages_url":"https://api.github.com/repos/9livesdata/whylog/languages","stargazers_url":"https://api.github.com/repos/9livesdata/whylog/stargazers","contributors_url":"https://api.github.com/repos/9livesdata/whylog/contributors","subscribers_url":"https://api.github.com/repos/9livesdata/whylog/subscribers","subscription_url":"https://api.github.com/repos/9livesdata/whylog/subscription","commits_url":"https://api.github.com/repos/9livesdata/whylog/commits{/sha}","git_commits_url":"https://api.github.com/repos/9livesdata/whylog/git/commits{/sha}","comments_url":"https://api.github.com/repos/9livesdata/whylog/comments{/number}","issue_comment_url":"https://api.github.com/repos/9livesdata/whylog/issues/comments{/number}","contents_url":"https://api.github.com/repos/9livesdata/whylog/contents/{+path}","compare_url":"https://api.github.com/repos/9livesdata/whylog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/9livesdata/whylog/merges","archive_url":"https://api.github.com/repos/9livesdata/whylog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/9livesdata/whylog/downloads","issues_url":"https://api.github.com/repos/9livesdata/whylog/issues{/number}","pulls_url":"https://api.github.com/repos/9livesdata/whylog/pulls{/number}","milestones_url":"https://api.github.com/repos/9livesdata/whylog/milestones{/number}","notifications_url":"https://api.github.com/repos/9livesdata/whylog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/9livesdata/whylog/labels{/name}","releases_url":"https://api.github.com/repos/9livesdata/whylog/releases{/id}","deployments_url":"https://api.github.com/repos/9livesdata/whylog/deployments","created_at":"2015-10-22T15:28:20Z","updated_at":"2016-02-28T22:54:29Z","pushed_at":"2016-04-18T16:23:40Z","git_url":"git://github.com/9livesdata/whylog.git","ssh_url":"git@github.com:9livesdata/whylog.git","clone_url":"https://github.com/9livesdata/whylog.git","svn_url":"https://github.com/9livesdata/whylog","homepage":null,"size":800,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":28,"forks":6,"open_issues":28,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/94"},"html":{"href":"https://github.com/9livesdata/whylog/pull/94"},"issue":{"href":"https://api.github.com/repos/9livesdata/whylog/issues/94"},"comments":{"href":"https://api.github.com/repos/9livesdata/whylog/issues/94/comments"},"review_comments":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/94/comments"},"review_comment":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/9livesdata/whylog/pulls/94/commits"},"statuses":{"href":"https://api.github.com/repos/9livesdata/whylog/statuses/c6d3d0634231eff79fa78030dc5736e152032c19"}}}}