tvalentyn commented on code in PR #23931: URL: https://github.com/apache/beam/pull/23931#discussion_r1044799836
########## sdks/python/apache_beam/testing/analyzers/github_issues_utils.py: ########## @@ -0,0 +1,187 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import json +import logging +import os +from typing import List +from typing import Optional +from typing import Tuple + +import pandas as pd +import requests + +try: + _GITHUB_TOKEN: Optional[str] = os.environ['GITHUB_TOKEN'] +except KeyError as e: + _GITHUB_TOKEN = None + logging.warning( + 'A Github Personal Access token is required ' + 'to create Github Issues.') + +# TODO: Change the REPO owner name to apache before merging. +_BEAM_GITHUB_REPO_OWNER = 'AnandInguva' +_BEAM_GITHUB_REPO_NAME = 'beam' +# Adding GitHub Rest API version to the header to maintain version stability. +# For more information, please look at +# https://github.blog/2022-11-28-to-infinity-and-beyond-enabling-the-future-of-githubs-rest-api-with-api-versioning/ # pylint: disable=line-too-long +_HEADERS = { + "Authorization": 'token {}'.format(_GITHUB_TOKEN), + "Accept": "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28" +} + +# Fill the GitHub issue description with the below variables. +_ISSUE_DESCRIPTION_HEADER = """ Review Comment: 1. Let's define _ISSUE_DESCRIPTION_HEADER in the same place where _TITLE_TEMPLATE is. Both are closely related. 2. Naming suggestion: _ISSUE_DESCRIPTION_TEMPLATE , _ISSUE_TITLE_TEMPLATE 3. _ISSUE_DESCRIPTION_TEMPLATE could be extended to smth like: ``` Performance change detected in <test path, ideally without replacing dots with _ so that it's easier to find in the codebase > for the metric <...> <runs that point anomaly>. For more information, see: <link to the playbook.> 4. nit: _ISSUE_TITLE_TEMPLATE could potentially be shortened, maybe use only the last identifier of the test name, so that we don't include `apache_beam.testing.benchmarks...` . Example: Performance change in pytorch_image_classification_benchmarks_13 : mean_load_model_latency_milli_secs ########## sdks/python/apache_beam/testing/analyzers/github_issues_utils.py: ########## @@ -0,0 +1,187 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import json +import logging +import os +from typing import List +from typing import Optional +from typing import Tuple + +import pandas as pd +import requests + +try: + _GITHUB_TOKEN: Optional[str] = os.environ['GITHUB_TOKEN'] +except KeyError as e: + _GITHUB_TOKEN = None + logging.warning( + 'A Github Personal Access token is required ' + 'to create Github Issues.') + +# TODO: Change the REPO owner name to apache before merging. +_BEAM_GITHUB_REPO_OWNER = 'AnandInguva' +_BEAM_GITHUB_REPO_NAME = 'beam' +# Adding GitHub Rest API version to the header to maintain version stability. +# For more information, please look at +# https://github.blog/2022-11-28-to-infinity-and-beyond-enabling-the-future-of-githubs-rest-api-with-api-versioning/ # pylint: disable=line-too-long +_HEADERS = { + "Authorization": 'token {}'.format(_GITHUB_TOKEN), + "Accept": "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28" +} + +# Fill the GitHub issue description with the below variables. +_ISSUE_DESCRIPTION_HEADER = """ Review Comment: 1. Let's define _ISSUE_DESCRIPTION_HEADER in the same place where _TITLE_TEMPLATE is. Both are closely related. 2. Naming suggestion: _ISSUE_DESCRIPTION_TEMPLATE , _ISSUE_TITLE_TEMPLATE 3. _ISSUE_DESCRIPTION_TEMPLATE could be extended to smth like: ``` Performance change detected in <test path, ideally without replacing dots with _ so that it's easier to find in the codebase > for the metric <...> <runs that point anomaly>. For more information, see: <link to the playbook.> ``` 4. nit: _ISSUE_TITLE_TEMPLATE could potentially be shortened, maybe use only the last identifier of the test name, so that we don't include `apache_beam.testing.benchmarks...` . Example: Performance change in pytorch_image_classification_benchmarks_13 : mean_load_model_latency_milli_secs -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
