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

can't access private repo from github #52

Open
ggg5269 opened this issue Apr 20, 2023 · 4 comments
Open

can't access private repo from github #52

ggg5269 opened this issue Apr 20, 2023 · 4 comments

Comments

@ggg5269
Copy link

ggg5269 commented Apr 20, 2023

Hi, I ran the code:

import httpimport
profile = """
[github]
headers:
  Authorization: token ghp_WjewI0mwxxxxxxxxxxxxxxxxez9"""

httpimport.set_profile(profile)

with httpimport.github_repo('myid', 'myrepo', profile='github'):
    import mypkg

but it gave ModuleNotFoundError.
could you please test with this function, and maybe make more instruction for us?

@janalysis
Copy link

This is working for me on our private repos. However, I have noticed there is a 5-10 minute delay before the import command picks up changes to the repository on GitHub.com, even though I can see the change right away at https://raw.githubusercontent.com/...

Would be nice if we could figure out what is causing this delay and mitigate it, since it slows down importing from one repo to another when you are making updates in the source repo.

@operatorequals
Copy link
Owner

Hello all!
I have the feeling that this is behaviour of Github itself, treating Python urllib User-Agent differently. This could make sense, as such User-Agents are sent by scripts and automated things,
and Github does not want to spend too much processing power to them (serving cached content more).

Yet, this is my speculation, as I can't find anything in the code, that would create such delays.

Can you please test the case of setting a different Usr-Agent header here:
https://github.com/operatorequals/httpimport/blob/master/httpimport.py#L105 and report back?

@janalysis
Copy link

I have added the following to my profile headers:
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:124.0) Gecko/20100101 Firefox/124.0

The import then picks up the changes within 1-2 minutes if I start a new python kernel. This is an improvement!

However, due to module caching within an existing python kernel it will never updated. Is there any reload function for httpimport like the reload function included with importlib? This is particular useful when working in development tools like Spyder where you are re-running code in the same kernel, vs calling a new python process every time the code runs.

@operatorequals
Copy link
Owner

I have added the following to my profile headers:
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:124.0) Gecko/20100101 Firefox/124.0

The import then picks up the changes within 1-2 minutes if I start a new python kernel. This is an improvement!

Glad it worked 🙃

However, due to module caching within an existing python kernel it will never updated. Is there any reload function for httpimport like the reload function included with importlib? This is particular useful when working in development tools like Spyder where you are re-running code in the same kernel, vs calling a new python process every time the code runs.

I have the feeling that using importlib.reload should work. I remember handling something like that at some point.

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

No branches or pull requests

3 participants