-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
141 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,22 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from skyplane.config import SkyplaneConfig | ||
from skyplane.gateway_version import gateway_version | ||
|
||
# version | ||
__version__ = "0.2.1" | ||
|
||
# paths | ||
skyplane_root = Path(__file__).parent.parent | ||
config_root = Path("~/.skyplane").expanduser() | ||
config_root.mkdir(exist_ok=True) | ||
|
||
if "SKYPLANE_CONFIG" in os.environ: | ||
config_path = Path(os.environ["SKYPLANE_CONFIG"]).expanduser() | ||
else: | ||
config_path = config_root / "config" | ||
|
||
aws_config_path = config_root / "aws_config" | ||
azure_config_path = config_root / "azure_config" | ||
azure_sku_path = config_root / "azure_sku_mapping" | ||
gcp_config_path = config_root / "gcp_config" | ||
|
||
key_root = config_root / "keys" | ||
__root__ = Path(__file__).parent.parent | ||
__config_root__ = Path("~/.skyplane").expanduser() | ||
__config_root__.mkdir(exist_ok=True) | ||
tmp_log_dir = Path("/tmp/skyplane") | ||
tmp_log_dir.mkdir(exist_ok=True) | ||
|
||
# definitions | ||
KB = 1024 | ||
MB = 1024 * 1024 | ||
GB = 1024 * 1024 * 1024 | ||
|
||
|
||
def format_bytes(bytes: int): | ||
if bytes < KB: | ||
return f"{bytes}B" | ||
elif bytes < MB: | ||
return f"{bytes / KB:.2f}KB" | ||
elif bytes < GB: | ||
return f"{bytes / MB:.2f}MB" | ||
else: | ||
return f"{bytes / GB:.2f}GB" | ||
|
||
|
||
if config_path.exists(): | ||
cloud_config = SkyplaneConfig.load_config(config_path) | ||
else: | ||
cloud_config = SkyplaneConfig.default_config() | ||
is_gateway_env = os.environ.get("SKYPLANE_IS_GATEWAY", None) == "1" | ||
|
||
# load gateway docker image version | ||
def gateway_docker_image(): | ||
return "public.ecr.aws/s6m1p0n8/skyplane:" + gateway_version | ||
__all__ = [ | ||
"__root__", | ||
"__config_root__", | ||
"__version__", | ||
"SkyplaneClient", | ||
"Dataplane", | ||
"TransferConfig", | ||
"AWSConfig", | ||
"AzureConfig", | ||
"GCPConfig", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import functools | ||
import os | ||
from pathlib import Path | ||
|
||
from skyplane import __config_root__ | ||
from skyplane.config import SkyplaneConfig | ||
|
||
|
||
@functools.lru_cache | ||
def load_config_path(): | ||
if "SKYPLANE_CONFIG" in os.environ: | ||
return Path(os.environ["SKYPLANE_CONFIG"]).expanduser() | ||
else: | ||
return __config_root__ / "config" | ||
|
||
|
||
@functools.lru_cache | ||
def load_cloud_config(path): | ||
if path.exists(): | ||
return SkyplaneConfig.load_config(path) | ||
else: | ||
return SkyplaneConfig.default_config() | ||
|
||
|
||
config_path = load_config_path() | ||
cloud_config = load_cloud_config(config_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.