Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit abde59b

Browse files
committed
Remove all 'import *'
1 parent 1c68c12 commit abde59b

File tree

9 files changed

+24
-13
lines changed

9 files changed

+24
-13
lines changed

paperspace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from . import scripts
77
from . import templates
88
from . import users
9-
from .config import *
9+
from .config import config
1010
from .jobs import run
1111
from .login import login, logout
1212
from .method import print_json_pretty

paperspace/config.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@
44

55
# TODO: this function is copy-pasted from login.py;
66
# there is something weird going one with imports in __init__.py and I'm unable to import apikey now
7-
def apikey():
8-
paperspace_dir = os.path.expanduser('~/.paperspace')
9-
config_path = os.path.join(paperspace_dir, 'config.json')
7+
def get_api_key(config_dir_path, config_file_name):
8+
paperspace_dir = os.path.expanduser(config_dir_path)
9+
config_path = os.path.join(paperspace_dir, config_file_name)
1010
if os.path.exists(config_path):
1111
config_data = json.load(open(config_path))
1212
if config_data and 'apiKey' in config_data:
1313
return config_data['apiKey']
1414
return ''
1515

1616

17-
_DEFAULT_PAPERSPACE_API_KEY = apikey()
1817
_DEFAULT_CONFIG_HOST = "https://api.paperspace.io"
1918
_DEFAULT_CONFIG_LOG_HOST = "https://logs.paperspace.io"
2019
_DEFAULT_CONFIG_EXPERIMENTS_HOST = "https://services.paperspace.io/experiments/v1/" # TODO: validate this
20+
_DEFAULT_CONFIG_DIR_PATH = "~/.paperspace"
21+
_DEFAULT_CONFIG_FILE_NAME = os.path.expanduser("config.json")
2122

2223

2324
class config(object):
2425
DEBUG = os.environ.get("PAPERSPACE_CLI_DEBUG") in ("true", "1")
25-
PAPERSPACE_API_KEY = os.environ.get("PAPERSPACE_API_KEY", _DEFAULT_PAPERSPACE_API_KEY)
2626
CONFIG_HOST = os.environ.get("PAPERSPACE_CONFIG_HOST", _DEFAULT_CONFIG_HOST)
2727
CONFIG_LOG_HOST = os.environ.get("PAPERSPACE_CONFIG_LOG_HOST", _DEFAULT_CONFIG_LOG_HOST)
2828
CONFIG_EXPERIMENTS_HOST = os.environ.get("PAPERSPACE_CONFIG_EXPERIMENTS_HOST", _DEFAULT_CONFIG_EXPERIMENTS_HOST)
29+
CONFIG_DIR_PATH = os.path.expanduser(os.environ.get("PAPERSPACE_CONFIG_PATH", _DEFAULT_CONFIG_DIR_PATH))
30+
CONFIG_FILE_NAME = os.environ.get("PAPERSPACE_CONFIG_FILE_NAME", _DEFAULT_CONFIG_FILE_NAME)
31+
PAPERSPACE_API_KEY = os.environ.get("PAPERSPACE_API_KEY", get_api_key(CONFIG_DIR_PATH, CONFIG_FILE_NAME))

paperspace/login.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import getpass
22
import json
3+
import os
34

45
import requests
56
from six.moves import input
67

78
from paperspace import logger
8-
from .config import *
9+
from .config import config
910
from .method import requests_exception_to_error_obj, response_error_check, status_code_to_error_obj
1011

1112
UNAUTHORIZED_EXTENDED_INFO = '\n\nNote: Please keep in mind that currently you can login only with the email and ' \

paperspace/machines.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from .method import *
1+
import time
2+
3+
import paperspace
4+
from .method import method
5+
26

37
def availability(params):
48
return method('machines', 'getAvailability', params)
@@ -52,6 +56,7 @@ def waitfor(params):
5256
state = machine['state']
5357
return machine
5458

59+
5560
def update(params):
5661
return method('machines', 'updateMachinePublic', params)
5762

paperspace/method.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
import os
13
import subprocess
24
import sys
35
import tempfile
@@ -6,7 +8,7 @@
68
import requests
79

810
from paperspace import logger
9-
from .config import *
11+
from .config import config
1012
from .version import version
1113

1214

paperspace/networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .method import *
1+
from .method import method
22

33
def list(params={}):
44
return method('networks', 'getNetworks', params)

paperspace/scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .method import *
1+
from .method import method
22

33
def create(params):
44
return method('scripts', 'createScript', params)

paperspace/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .method import *
1+
from .method import method
22

33
def list(params={}):
44
return method('templates', 'getTemplates', params)

paperspace/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .method import *
1+
from .method import method
22

33
def list(params={}):
44
return method('users', 'getUsers', params)

0 commit comments

Comments
 (0)