Skip to main content

A python sdk for AIIT OS

Project description

AIIT-SDK

安装

pip install aiit_sdk

如果需要指定安装源,可以使用 -i 参数

pip install aiit-sdk  --index-url https://pypi.org/simple/

版本更新,可以使用 --upgrade 参数更新

pip install --upgrade aiit-sdk  --index-url https://pypi.org/simple/

使用说明

登陆模块

在 settings.py 的 SIMPLE_JWT.AUTH_TOKEN_CLASSES 参数下面添加 aiit_sdk.auth.AiitToken

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(days=1),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
    'ROTATE_REFRESH_TOKENS': True,
    'BLACKLIST_AFTER_ROTATION': True,

    'ALGORITHM': 'HS256',
    'SIGNING_KEY': JWT_SIGNING_KEY,
    'VERIFYING_KEY': None,

    'AUTH_HEADER_TYPES': ('Bearer', 'JWT'),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',

    'AUTH_TOKEN_CLASSES': (
        'aiit_sdk.auth.AiitToken',  # 允许大数据OS颁发的Token访问
        'rest_framework_simplejwt.tokens.AccessToken',
    ),
    'TOKEN_TYPE_CLAIM': 'token_type',

    'JTI_CLAIM': 'jti',

    'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp',
    'SLIDING_TOKEN_LIFETIME': timedelta(days=7),
    'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=30),
}

接口返回

from aiit_sdk.response import APIResponse


class FileUploadView(APIView):
    def post(self, request):
        #  业务代码
        data = {}  # 要返回的数据
        return APIResponse(data=data)

分页模块

默认分页模块的配置

将 settings.py 的 REST_FRAMEWORK.DEFAULT_PAGINATION_CLASS 参数设置成 aiit_sdk.page.NormalResultsSetPagination

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_simplejwt.authentication.JWTAuthentication',
        'rest_framework_simplejwt.authentication.JWTTokenUserAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        # 'rest_framework.permissions.IsAuthenticated',
    ),
    'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S',
    'DEFAULT_PAGINATION_CLASS': 'aiit_sdk.page.NormalResultsSetPagination',  # 默认分页模块的配置
    'DEFAULT_FILTER_BACKENDS': (
        'django_filters.rest_framework.DjangoFilterBackend',
        'rest_framework.filters.OrderingFilter',
        'rest_framework.filters.SearchFilter'
    ),
    'PAGE_SIZE': 20,
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}

算法调用模块

通过算法名称调用算法,如果一个算法有多个版本,默认调用最后上传的那个版本。

from aiit_sdk.algo import exec_algo


res = exec_algo(algo_name='cv_name_extra', **params)

参数:

  • algo_name:算法名称;
  • params:调用算法的参数,每个算法有所不同。

文件存储

将 settings.py 的 DEFAULT_FILE_STORAGE 参数设置成 aiit_sdk.storage.AiitStorage

DEFAULT_FILE_STORAGE = 'aiit_sdk.storage.AiitStorage'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiit_sdk-0.0.5.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

aiit_sdk-0.0.5-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file aiit_sdk-0.0.5.tar.gz.

File metadata

  • Download URL: aiit_sdk-0.0.5.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for aiit_sdk-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8ca6ad0a49f759994f21921ac0d96c62397e91559f7e97fc18cbd79898d36b4a
MD5 5eb92ddd56682ce0872c7fc3b540f875
BLAKE2b-256 ff738c671879239c2979d6c7e199f0a71e6d70f7accff2deb37178340a37eb6d

See more details on using hashes here.

File details

Details for the file aiit_sdk-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: aiit_sdk-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for aiit_sdk-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c702843dbc85c6b4bbb28318cc5a8cafbff81c4b10abad6dbba2970f5f5738cd
MD5 82e4c64980f8a8db9e23b825d353d750
BLAKE2b-256 22408ba7a434ed1f06a2c183899085ea9901ca9057deddb97e94b6b361a141dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page