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

mkhtml: check for addon_path #3571

Merged
merged 2 commits into from
Apr 12, 2024
Merged

mkhtml: check for addon_path #3571

merged 2 commits into from
Apr 12, 2024

Conversation

mmacata
Copy link
Contributor

@mmacata mmacata commented Apr 9, 2024

This PR suggests to add a check for an empty addon_path.
The default value is set to addon_path = None in L889 and there are circumstances where it is not overwritten. As far as I see it, this would prevent the code from requesting a wrong path in the following method returning the latest commit of the whole addon repository instead of the latest commit for the addon.

Manual page generation here is really new to me so I am not sure about all the different variations in which this script might be called and if I oversee something. Background is that I am using the script to generate manual pages for addons not in the official addon repository and this PR would prevent multiple unneccessary requests to the github API.

@github-actions github-actions bot added the Python Related code is in Python label Apr 9, 2024
@tmszi tmszi self-requested a review April 10, 2024 09:09
Copy link
Member

@tmszi tmszi left a comment

Choose a reason for hiding this comment

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

Condition if addon_path is not None: should be inside body of get_git_commit_from_rest_api_for_addon_repo() function, line 294. See the code line comment on the line 291, please.

grass/utils/mkhtml.py

Lines 278 to 294 in afce9ea

def get_git_commit_from_rest_api_for_addon_repo(
addon_path,
src_dir,
git_log=None,
):
"""Get Git commit from remote GitHub REST API for addon repository
:param str addon_path: addon path
:param str src_dir: addon source dir
:param dict git_log: dict which store last commit and commnit date
:return dict git_log: dict which store last commit and commnit date
"""
# Accessed date time if getting commit from GitHub REST API wasn't successful
if not git_log:
git_log = get_default_git_log(src_dir=src_dir)
grass_addons_url = (

Because if addon is not official addon, func must return date (access date of addon directory) with git_log variable, example {'commit': 'unknown', 'date': 'Wednesday Apr 10 11:48:39 2024'}, line 293.

And date and time inside manual page looks like

Accessed: Wednesday Apr 10 11:48:39 2024

instead of

Latest change: Wednesday Mar 01 21:08:00 2023 in commit:1a96f69ccf430caa03bec8dbfc990c07c81f3164

Attached patch file:
patch.zip

Apply patch with:

git am < 0001-utils-do-not-make-unnecessary-request-to-addons-repo.patch

@mmacata
Copy link
Contributor Author

mmacata commented Apr 10, 2024

Thanks for the feedback, I applied it. But this way there is no chance the information can be retrieved from the get_git_commit_from_file method in that case?

@tmszi tmszi closed this Apr 10, 2024
@tmszi tmszi reopened this Apr 10, 2024
@tmszi
Copy link
Member

tmszi commented Apr 10, 2024

But this way there is no chance the information can be retrieved from the get_git_commit_from_file method in that case?

Only official addons are supported now (during addon compilation is downloaded source code without Git repo, and getting commit is done by request/response from the official GitHub GRASS GIS Addons repository) .

Else branch with get_git_commit_from_file() function retrieve commits from file (if core_modules_with_last_commit.json file exists) during compilation GRASS GIS core modules but not addons.

grass/utils/mkhtml.py

Lines 407 to 409 in 49e1353

# During GRASS GIS compilation from source code without Git
else:
return get_git_commit_from_file(src_dir=src_dir)

I apologize for close/reopen PR. I accidentally hit Close with comment button.

@mmacata
Copy link
Contributor Author

mmacata commented Apr 11, 2024

Ok thanks for clarification!
I tested my use case with these changes and everything runs well.

I am not sure about the failing Python Code Quality Checks though. The error there doesn't seem to be related to linting:

Error: Failed to FinalizeArtifact: Received non-retryable error: Failed request: (403) Forbidden: Error from intermediary with HTTP status code 403 "Forbidden"

@tmszi is it possible to retry the failing check? I don't have access rights to do so.

@echoix
Copy link
Member

echoix commented Apr 11, 2024

It seemed like an intermittent failure..
If the failure was yesterday, it might have been https://www.githubstatus.com/incidents/9zq8p50p7tkh

@tmszi tmszi self-requested a review April 11, 2024 18:49
@mmacata
Copy link
Contributor Author

mmacata commented Apr 12, 2024

That could be the cause, yes, now it runs through :)

May someone with merge rights merge this?

@tmszi tmszi merged commit 20a7620 into OSGeo:main Apr 12, 2024
51 checks passed
@mmacata mmacata deleted the mkhtml-addon_path branch April 12, 2024 08:17
tmszi added a commit that referenced this pull request Apr 12, 2024
… addon path is None (#3571)

---------

Co-authored-by: Tomas Zigo <[email protected]>
@tmszi tmszi added this to the 8.4.0 milestone Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants