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

1st_version of the github_auto_add #235

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

SeverusYixin
Copy link
Collaborator

@SeverusYixin SeverusYixin commented Oct 10, 2024

Hi @haesleinhuepf, would you mind helping me review it?

This PR relates to #185
This PR closes #185

@SeverusYixin
Copy link
Collaborator Author

SeverusYixin commented Oct 10, 2024

I changed it according to auto-add-zenodo-entry.py, in theory it should work, I can't test it locally. So there is a problem, for example, when I give it this URL 'https://github.com/guiwitz/Python_image_processing', which should be the name 'Python_image_processing' or 'Image processing with Python'.

- issue (int): Issue number containing the GitHub link.

Example:
python auto_add_github_entry.py "username/repo" 123
Copy link
Member

@haesleinhuepf haesleinhuepf Oct 10, 2024

Choose a reason for hiding this comment

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

Suggested change
python auto_add_github_entry.py "username/repo" 123
python scripts/auto-add-github-resources.py username/repo 123

I presume this is correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have deleted it. I wanted to test it locally or on my github, but it seems I'm not allowed to.

@SeverusYixin
Copy link
Collaborator Author

Why can I not write this link like you did "

# This script is executed when a new issue is created on our github repository.
"?

Copy link
Member

@haesleinhuepf haesleinhuepf left a comment

Choose a reason for hiding this comment

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

Hi @SeverusYixin ,

awesome, thanks for this! Two things:

  1. Before sending a PR, please check if the tool works as you describe it in the documentation.
  2. I just tested it and received an error message. That's the command I ran:
python scripts/auto-add-github-resources.py nfdi4bioimage/training 236

And that's the error:

-> get_conversation_on_issue(nfdi4bioimage/training, 236)
Request GET /repos/rmassei/ymia_python_event_series_material/collaborators?per_page=1 failed with 403: Forbidden
Traceback (most recent call last):
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 139, in <module>
    main()
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 34, in main
    github_data_dict = complete_github_data(github_repo_url)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 97, in complete_github_data
    if collaborators.totalCount > 0:
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\PaginatedList.py", line 192, in totalCount
    headers, data = self.__requester.requestJsonAndCheck(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 550, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 715, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 812, in __requestEncode
    status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 846, in __requestRaw
    response = cnx.getresponse()
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 198, in getresponse
    r = verb(
        ^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\urllib3\connectionpool.py", line 934, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\GithubRetry.py", line 187, in increment
    raise Requester.createException(response.status, response.headers, content)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
github.GithubException.GithubException: 403 {"message": "Must have push access to view repository collaborators.", "documentation_url": "https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators", "status": "403"}

Let me know if I should try again!

And thanks again for working on this. This will be cool to have!

Best,
Robert

@SeverusYixin
Copy link
Collaborator Author

Hi @SeverusYixin ,

awesome, thanks for this! Two things:

  1. Before sending a PR, please check if the tool works as you describe it in the documentation.
  2. I just tested it and received an error message. That's the command I ran:
python scripts/auto-add-github-resources.py nfdi4bioimage/training 236

And that's the error:

-> get_conversation_on_issue(nfdi4bioimage/training, 236)
Request GET /repos/rmassei/ymia_python_event_series_material/collaborators?per_page=1 failed with 403: Forbidden
Traceback (most recent call last):
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 139, in <module>
    main()
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 34, in main
    github_data_dict = complete_github_data(github_repo_url)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\structure\code\training\scripts\auto-add-github-resources.py", line 97, in complete_github_data
    if collaborators.totalCount > 0:
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\PaginatedList.py", line 192, in totalCount
    headers, data = self.__requester.requestJsonAndCheck(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 550, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 715, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 812, in __requestEncode
    status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 846, in __requestRaw
    response = cnx.getresponse()
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\Requester.py", line 198, in getresponse
    r = verb(
        ^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\requests\adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\urllib3\connectionpool.py", line 934, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\devbio-napari-env\Lib\site-packages\github\GithubRetry.py", line 187, in increment
    raise Requester.createException(response.status, response.headers, content)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
github.GithubException.GithubException: 403 {"message": "Must have push access to view repository collaborators.", "documentation_url": "https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators", "status": "403"}

Let me know if I should try again!

And thanks again for working on this. This will be cool to have!

Best, Robert

The problem is that I can not test it, it told me the scads.ai clould refuse me XD

@haesleinhuepf
Copy link
Member

What is "scads.ai clould" in this context? What was the exact error message?

@SeverusYixin
Copy link
Collaborator Author

I have found another way to test. The "scads.ai cloud" problem is if I use my own github to test, I think my own github can not edit the thing on our repositories, e.g. create a PR.

@haesleinhuepf
Copy link
Member

The error above is not about our repository:

Request GET /repos/rmassei/ymia_python_event_series_material/collaborators?per_page=1 failed with 403: Forbidden
...
Must have push access to view repository collaborators.

The error happens when accessing the other repository. I'd say we will not be able to read out collaborators from remote repositories.

@SeverusYixin
Copy link
Collaborator Author

The error above is not about our repository:

Request GET /repos/rmassei/ymia_python_event_series_material/collaborators?per_page=1 failed with 403: Forbidden
...
Must have push access to view repository collaborators.

The error happens when accessing the other repository. I'd say we will not be able to read out collaborators from remote repositories.

Yes, I used the code snippet to check locally that the link to our repository is no problem, it show me as PS C:\Users\huang\Documents\GitHub\training\scripts> & 'c:\Users\huang\AppData\Local\Programs\ Python\Python312\python. exe' 'c:\Users\huang.vscode\extensions\ms-python.debugpy-2024.10.0-win32-x64\bundled\libs\debugpy\adapter/ ... /... \debugpy\launcher' "51870" "--" "C:\Users\huang\Documents\GitHub\training\scripts\test.py"
Token found: githu
Repository successfully accessed: NFDI4BIOIMAGE/training
PS C:\Users\huang\Documents\GitHub\training\scripts>

I'm trying to see if this can be avoided, but nothing I've seen so far seems to work! Or maybe not with github token, I'm not sure

@haesleinhuepf
Copy link
Member

nothing I've seen so far seems to work!

Yes, it is possible that this will not work. Do you have an overview about which meta data we can access and which not?

@SeverusYixin
Copy link
Collaborator Author

nothing I've seen so far seems to work!

Yes, it is possible that this will not work. Do you have an overview about which meta data we can access and which not?

At the moment, it looks like the request will be denied when you try to access it with github token.

@haesleinhuepf
Copy link
Member

Can you please try "repo.get_contributors()" instead of "repo.get_collaborators()"?

@SeverusYixin
Copy link
Collaborator Author

Can you please try "repo.get_contributors()" instead of "repo.get_collaborators()"?

Let me try

@haesleinhuepf
Copy link
Member

Did it work?

@SeverusYixin
Copy link
Collaborator Author

Did it work?

no

@SeverusYixin
Copy link
Collaborator Author

Please do not merge. There are still some details to discuss :)

  1. Currently it looks like Add https://github.com/rmassei/ymia_python_event_series_material #238, so again, what should the name be, "ymia_python_event_series_material" or "YMIA - Python-Based Event Series Training Material"?

  2. and for tags, do we need this "tags: No tags available"? or this "tags: "

@haesleinhuepf
Copy link
Member

  1. "ymia_python_event_series_material" or "YMIA - Python-Based Event Series Training Material"?

I would use whatever the github returns as repo.name

2. and for tags, do we need this "tags: No tags available"? or this "tags: "

If there are no tags, we should not have a "tag:" in our yaml.

@haesleinhuepf
Copy link
Member

no

Consider posting an error message, in case you wish that I assist you.

@SeverusYixin
Copy link
Collaborator Author

Consider posting an error message, in case you wish that I assist you.

Already solved, thank you if I need that I will post a error message. Thank you again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-add github resources
2 participants