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

✨Create new project without internet #175

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

Conversation

omegaStag
Copy link
Contributor

@omegaStag omegaStag commented Oct 29, 2021

Summary:

  • Added 'download-ok' switch to new-project to decide if remote templates can be used in creating projects
  • Put some lines from new-project into new helper function _create_project for this purpose (and to make click happy)
  • Due to a generic Exception being raised when there is no internet connection (instead of an actual ConnectionError for some reason), added a nested try and except statement to attempt a new project with local templates if remote templates cannot be reached, raises another exception if that fails
  • Fixed resolved_templates so that it actually takes into account whether 'download-ok' is true or false before downloading from remote
  • "Can't GitHub" error could be placed before the output telling user which templates are used, but I'm not sure how to place it as I don't want it to trigger before a potential Exception due to something that is NOT a lack of internet
  • Removed allow_online: bool = True from top of resolve_templates to make above features work
  • Removed allow_online=download_ok from template = self.resolve_template(identifier=identifier, allow_online=download_ok, **kwargs) because resolve_templates now takes 'download_ok' into account seperately

Motivation:

Let users make new project from local templates without internet

References (optional):

Closes #91

Test Plan:

  1. (With internet) Purge templates, download 2nd most recent versions of okapilib and kernel, then run pros c n . --no-download to demonstrate that the most recent remote templates are not applied, and the local templates are used instead
    image

  2. (Without internet) Create a new project with pros c n .. There will be an error that alerts the user that the CLI can't connect to GitHub, and it creates a project with the local templates you have instead.
    image

  3. (Without internet) pros c n . --download. Even if --download is specified, if there is no internet it creates from local templates without problem.
    image

  4. (With internet) pros c n .. Newest versions of templates from remote are automatically downloaded and applied as usual.
    image

  5. (Without internet) pros c n . creates a new project with the most recent local templates.
    image

new-project now has an --allow-online/--no-online switch that allows for creating a project with or without remote templates.
also, made a helper _create_project function that new_project calls
FIXME: ConnectionErrors are not being caught (to make projects with local templates if no internet), unpoggers!
Will elaborate in PR
WillXuCodes
WillXuCodes previously approved these changes Nov 1, 2021
Copy link
Member

@WillXuCodes WillXuCodes left a comment

Choose a reason for hiding this comment

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

Unless anyone else has any other comments, this seems to work and be good based on the test cases.

@edjubuh
Copy link
Member

edjubuh commented Nov 1, 2021

I'd rather just fix resolve_templates to always be OK if a remote depot is unavailable.

e.g. try block around:

online_results = filter(lambda t: t.satisfies(query, kernel_version=kernel_version),
depot.get_remote_templates(force_check=force_refresh, **kwargs))
if unique:
results.update(online_results)
else:
results.extend(online_results)

@omegaStag
Copy link
Contributor Author

I'd rather just fix resolve_templates to always be OK if a remote depot is unavailable.

e.g. try block around:

online_results = filter(lambda t: t.satisfies(query, kernel_version=kernel_version),
depot.get_remote_templates(force_check=force_refresh, **kwargs))
if unique:
results.update(online_results)
else:
results.extend(online_results)

image

When I try to have the try in resolve_templates it generates a bunch of error messages, seemingly because it doesn't like calling itself... but makes the project anyways? I have no idea

@WillXuCodes
Copy link
Member

I'm not seeing the try except block anywhere, have you pushed it yet? Also, what are you doing with the exception after catching it? It seems like it's just getting printed and moving on.

@WillXuCodes WillXuCodes dismissed their stale review November 29, 2021 21:06

(not actually approving the PR)

@omegaStag
Copy link
Contributor Author

With internet
image

No internet
image
There's not really an easy way to get rid of the duplicate warnings but I think that having them is better than not having any indication of no connection at all.

WillXuCodes
WillXuCodes previously approved these changes Dec 28, 2021
Copy link
Member

@WillXuCodes WillXuCodes left a comment

Choose a reason for hiding this comment

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

I'm approving this so we can get this shipped out the door a little quicker. The cosmetic issue of the warning appearing twice should be a seperate issue we open after the PR and somebody else could handle it as their entry level issue :P . Great work!

@WillXuCodes WillXuCodes dismissed their stale review December 28, 2021 03:10

(not cosmetic apparently)

@omegaStag omegaStag added enhancement This builds on top of an existing feature on hold This may be revisited in the future labels Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This builds on top of an existing feature on hold This may be revisited in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a project without internet
3 participants