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

Project restructure to make it easier to implement more backends #32

Merged
merged 9 commits into from
Jul 13, 2020

Conversation

sritchie
Copy link
Collaborator

@sritchie sritchie commented Jun 29, 2020

This PR refactors:

  • caliban.config into caliban.config and caliban.config.experiment
  • caliban.util becomes caliban.util and caliban.util.{argparse, auth, fs, tqdm}
  • caliban.cloud.* becomes caliban.platform.cloud.*
  • caliban.docker becomes caliban.docker.{build, push} and caliban.platform.{run, shell, notebook}

The tests are also split accordingly.

I snuck in ONE bugfix that appeared during testing. I moved our method of generating credentials from gcloud auth login over to caliban.util.auth so that I could reuse it in the caliban history API. We had one spot where we were calling discovery.build and NOT passing any credentials, which threw an error when the user didn't have GOOGLE_APPLICATION_CREDENTIALS specified.

I also removed unused imports and sorted imports wherever I could.

Why?

The project needed it; specifically this is going to make it easier to increase test coverage, and to get the .calibanconfig.json code working with a proper schema, so that we can start to add options there.

I really want to make the platforms pluggable, and sorting them out into separate modules is the first step.

@sritchie sritchie force-pushed the sritchie/restructure branch from 23281bc to 76fe3e0 Compare July 10, 2020 19:00
@codecov
Copy link

codecov bot commented Jul 11, 2020

Codecov Report

Merging #32 into master will increase coverage by 1.04%.
The diff coverage is 60.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
+ Coverage   46.52%   47.57%   +1.04%     
==========================================
  Files          17       26       +9     
  Lines        2764     2825      +61     
==========================================
+ Hits         1286     1344      +58     
- Misses       1478     1481       +3     
Impacted Files Coverage Δ
caliban/platform/cloud/types.py 89.47% <ø> (ø)
caliban/platform/gke/types.py 63.33% <ø> (ø)
caliban/platform/run.py 25.71% <25.71%> (ø)
caliban/platform/gke/cluster.py 30.05% <30.00%> (ø)
caliban/platform/shell.py 34.48% <34.48%> (ø)
caliban/docker/build.py 31.49% <40.00%> (ø)
caliban/platform/gke/cli.py 21.83% <42.85%> (ø)
caliban/platform/notebook.py 45.00% <45.00%> (ø)
caliban/util/argparse.py 47.36% <47.36%> (ø)
caliban/config/__init__.py 47.94% <47.94%> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85c0bc3...3329f46. Read the comment docs.

@sritchie sritchie changed the title Project restructure to make it easier to implement more backends [draft] Project restructure to make it easier to implement more backends Jul 11, 2020
@sritchie
Copy link
Collaborator Author

@ajslone , I've tested caliban {shell, run, cloud}, and caliban status just with the basic command, no options. Would you mind helping me test the GKE code, and fixing any busted imports that I've forgotten?

Thank you!

Copy link
Collaborator

@ajslone ajslone left a comment

Choose a reason for hiding this comment

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

LGTM. This re-org should make the structure of the project clearer.

@@ -244,8 +244,12 @@ def _get_caip_job_name(j: Job) -> str:


# ----------------------------------------------------------------------------
def _get_caip_job_api() -> Any:
return discovery.build('ml', 'v1', cache_discovery=False).projects().jobs()
def _get_caip_job_api(credentials_path: Optional[str] = None) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice addition here.

import caliban.history.cli
import caliban.platform.cloud.core as cloud
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely like the platform.xxx structure better here.

# credentials.
credentials = gcloud_auth_credentials()

credentials = ua.gcloud_credentials(credentials_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

cleaner, nice

@sritchie sritchie merged commit 6edb9b5 into master Jul 13, 2020
@sritchie sritchie deleted the sritchie/restructure branch July 13, 2020 17:37
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.

2 participants