diff --git a/roboflow/__init__.py b/roboflow/__init__.py index d608ea03..bfb0d133 100644 --- a/roboflow/__init__.py +++ b/roboflow/__init__.py @@ -237,16 +237,16 @@ def workspace(self, the_workspace=None): if the_workspace is None: the_workspace = self.current_workspace - + if self.api_key: # Check if api_key was passed during __init__ workspace_api_key = load_roboflow_api_key(the_workspace) api_key = workspace_api_key or self.api_key list_projects = rfapi.get_workspace(api_key, the_workspace) return Workspace(list_projects, api_key, the_workspace, self.model_format) - + elif self.api_key in DEMO_KEYS: return Workspace({}, self.api_key, the_workspace, self.model_format) - + else: raise ValueError("A valid API key must be provided.") diff --git a/roboflow/core/project.py b/roboflow/core/project.py index 28fdd5b7..198afb33 100644 --- a/roboflow/core/project.py +++ b/roboflow/core/project.py @@ -53,7 +53,7 @@ def __init__(self, api_key: str, a_project: dict, model_format: Optional[str] = >>> project = rf.workspace().project("PROJECT_ID") """ - + if api_key: self.__api_key = api_key self.annotation = a_project["annotation"] @@ -73,14 +73,13 @@ def __init__(self, api_key: str, a_project: dict, model_format: Optional[str] = temp = self.id.rsplit("/") self.__workspace = temp[0] self.__project_name = temp[1] - + elif DEMO_KEYS: self.__api_key = DEMO_KEYS[0] self.model_format = model_format - + else: raise ValueError("A valid API key must be provided.") - def get_version_information(self): """ diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 6288c966..3e0b3218 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -132,7 +132,7 @@ def __init__( self.model = KeypointDetectionModel(self.__api_key, self.id, version=version_without_workspace) else: self.model = None - + elif DEMO_KEYS: api_key = DEMO_KEYS[0] if api_key == "coco-128-sample": diff --git a/roboflow/core/workspace.py b/roboflow/core/workspace.py index 00a90716..c5f67a3d 100644 --- a/roboflow/core/workspace.py +++ b/roboflow/core/workspace.py @@ -23,11 +23,11 @@ class Workspace: """ Manage a Roboflow workspace. """ + def __init__(self, info, api_key, default_workspace, model_format): - if api_key: - self.__api_key = api_key - + self.__api_key = api_key + workspace_info = info["workspace"] self.name = workspace_info["name"] self.project_list = workspace_info["projects"] @@ -43,7 +43,7 @@ def __init__(self, info, api_key, default_workspace, model_format): else: raise ValueError("A valid API key must be provided.") - + def list_projects(self): """ Print all projects in the workspace to the console. diff --git a/roboflow/roboflowpy.py b/roboflow/roboflowpy.py index c26b8672..cf3280b9 100755 --- a/roboflow/roboflowpy.py +++ b/roboflow/roboflowpy.py @@ -113,17 +113,17 @@ def get_workspace(args): print(json.dumps(workspace_json, indent=2)) - def get_workspace_project_version(args): - #api_key = load_roboflow_api_key(args.workspaceId) + # api_key = load_roboflow_api_key(args.workspaceId) rf = roboflow.Roboflow(args.api_key) workspace = rf.workspace() - print('workspace',workspace) + print("workspace", workspace) project = workspace.project(args.project) - print('project',project) + print("project", project) version = project.version(args.version_number) - print('version',version) - + print("version", version) + + def get_project(args): workspace_url = args.workspace or get_conditional_configuration_variable("RF_WORKSPACE", default=None) api_key = load_roboflow_api_key(workspace_url) @@ -174,7 +174,6 @@ def _argparser(): _add_upload_model_parser(subparsers) _add_get_workspace_project_version_parser(subparsers) - return parser @@ -424,6 +423,7 @@ def _add_upload_model_parser(subparsers): ) upload_model_parser.set_defaults(func=upload_model) + def _add_get_workspace_project_version_parser(subparsers): workspace_project_version_parser = subparsers.add_parser( "get_workspace_info", @@ -451,7 +451,8 @@ def _add_get_workspace_project_version_parser(subparsers): help="version number to upload the model to", ) workspace_project_version_parser.set_defaults(func=get_workspace_project_version) - + + def _add_login_parser(subparsers): login_parser = subparsers.add_parser("login", help="Log in to Roboflow") login_parser.set_defaults(func=login)