Skip to content

Commit

Permalink
Merge pull request #123 from Superb-AI-Suite/v0.19.0
Browse files Browse the repository at this point in the history
v0.19.0 Change sdk to use new phy-credit
  • Loading branch information
Min-june authored Mar 19, 2024
2 parents 23c5e97 + 8558c62 commit bc7cb9c
Show file tree
Hide file tree
Showing 48 changed files with 2,890 additions and 1,323 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ wget-log*
**/*.ipynb

# workspace
workspace/
workspace/
notebooks/**
1,091 changes: 539 additions & 552 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def load_config():
"colorama==0.4.3",
"commonmark==0.9.1",
"idna==2.9",
"importlib-metadata<=7.0.1, >=3.6; python_version < '3.9'",
"importlib-metadata<=4.5.0, >=3.6; python_version < '3.9'",
"keyring==21.2.1",
"packaging<=23.2",
"packaging==20.4",
"pkginfo==1.5.0.1",
"pprintpp==0.4.0",
"readme-renderer==26.0",
"requests>=2.31.0,<3.0.0",
"rich==10.2.2",
"typing-extensions<4.9.0,>=3.7.4",
"typing-extensions<4.0.0,>=3.7.4",
"six==1.15.0",
"tqdm==4.46.1",
"botocore>=1.20.82",
Expand Down
2 changes: 1 addition & 1 deletion spb/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def execute(self, query: str, values: dict = {}):
):
self.history.appendleft({"NotFoundException": data})
raise NotFoundException(
"Not Found Exception: Open API returns not found exception with status code 404"
"Cannot find the requested resource. Check your request"
)
elif int(error["extensions"]["code"]) == 409:
self.history.appendleft({"ConflictException": data})
Expand Down
21 changes: 16 additions & 5 deletions spb/image_sdk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import urllib
import os

from typing import Union, Optional, List

Expand All @@ -10,7 +11,10 @@
from spb.labels.label import WorkappType, Tags
from spb.labels.manager import LabelManager
from spb.users.user import User
from spb.utils import deprecated
from spb.utils import (
deprecated,
retrieve_file,
)


class DataHandle(object):
Expand Down Expand Up @@ -110,16 +114,23 @@ def get_label_interface(self):
# Simple SDK functions
##############################

def download_image(self, download_to=None):
def download_image(self, download_to="./"):
self._describe_data_detail()
if self._is_expired_url():
return None, None

if download_to is None:
download_to = self._data.data_key
print("[INFO] Downloaded to {}".format(download_to))

return urllib.request.urlretrieve(self._data.data_url, download_to)
path = self._data.data_key.lstrip("/")
full_path = os.path.join(
download_to,
path,
)
print("[INFO] Downloaded to {}".format(full_path))
return retrieve_file(
url=self._data.data_url,
file_path=full_path
)

def get_image(self):
self._describe_data_detail()
Expand Down
5 changes: 5 additions & 0 deletions spb/libs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .phy_credit import phy_credit

__all__ = (
"phy_credit",
)
15 changes: 15 additions & 0 deletions spb/libs/phy_credit/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pytest = "*"
semver = "*"
phy-credit = {path = "."}

[dev-packages]
pytest = "*"

[requires]
python_version = "3.9"
146 changes: 146 additions & 0 deletions spb/libs/phy_credit/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions spb/libs/phy_credit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from .phy_credit import imageV2, video
from .phy_credit import imageV2, video, pointclouds, common, exceptions


__all__ = (
"common",
"imageV2",
"video",
# 'team_name',
# 'access_key',
# 'ProjectClient',
# 'LabelClient',
# 'DataClient',
# 'Client',
"pointclouds",
"exceptions",
)
2 changes: 1 addition & 1 deletion spb/libs/phy_credit/phy_credit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.4"
__version__ = "0.6.5"
4 changes: 4 additions & 0 deletions spb/libs/phy_credit/phy_credit/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import semver

from .label import ClassType


def is_camel_version(label_interface):
return (
Expand All @@ -13,3 +15,5 @@ def is_camel_version(label_interface):
# "PropertyOptionsDef",
# "PropertyOptionsItemDef",
# )

__all__ = ("ClassType",)
78 changes: 78 additions & 0 deletions spb/libs/phy_credit/phy_credit/common/deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import functools
import inspect
import warnings

string_types = (type(b''), type(u''))


def deprecated(reason):
"""
This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
"""

if isinstance(reason, string_types):

# The @deprecated is used with a 'reason'.
#
# .. code-block:: python
#
# @deprecated("please, use another function")
# def old_function(x, y):
# pass

def decorator(func1):

if inspect.isclass(func1):
fmt1 = "Call to deprecated class {name} ({reason})."
else:
fmt1 = "Call to deprecated function {name} ({reason})."

@functools.wraps(func1)
def new_func1(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
fmt1.format(name=func1.__name__, reason=reason),
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
return func1(*args, **kwargs)

return new_func1

return decorator

elif inspect.isclass(reason) or inspect.isfunction(reason):

# The @deprecated is used without any 'reason'.
#
# .. code-block:: python
#
# @deprecated
# def old_function(x, y):
# pass

func2 = reason

if inspect.isclass(func2):
fmt2 = "Call to deprecated class {name}."
else:
fmt2 = "Call to deprecated function {name}."

@functools.wraps(func2)
def new_func2(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
fmt2.format(name=func2.__name__),
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
return func2(*args, **kwargs)

return new_func2

else:
raise TypeError(repr(type(reason)))
Loading

0 comments on commit bc7cb9c

Please sign in to comment.