Skip to content

Commit

Permalink
Merge pull request #183 from inverted-ai/develop
Browse files Browse the repository at this point in the history
Release 0.0.15rc0
  • Loading branch information
Ruishenl committed Mar 2, 2024
2 parents 26cf7ba + ede7603 commit 26fbd63
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 30 deletions.
4 changes: 2 additions & 2 deletions examples/simulation/car.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import Optional
import pygame
from pygame.math import Vector2
from pydantic import validate_arguments
from pydantic import validate_call
from invertedai.common import AgentState, AgentAttributes, RecurrentState
from collections import deque
from simulation.utils import MAX_HISTORY_LEN, AGENT_FOV, Rectangle
from uuid import uuid1 as UUID


class Car:
@validate_arguments
@validate_call
def __init__(self,
agent_attributes: Optional[AgentAttributes],
agent_states: Optional[AgentState],
Expand Down
3 changes: 1 addition & 2 deletions invertedai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import importlib.metadata
__version__ = importlib.metadata.version("invertedai")
from distutils.util import strtobool

from invertedai.api.light import light
Expand Down Expand Up @@ -57,5 +58,3 @@
"async_drive",
"async_blame",
]

__version__ = importlib.metadata.version("invertedai")
6 changes: 3 additions & 3 deletions invertedai/api/blame.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from typing import List, Optional, Tuple, Dict
from pydantic import BaseModel, validate_arguments
from pydantic import BaseModel, validate_call

import invertedai as iai
from invertedai.api.config import TIMEOUT, should_use_mock_api
Expand All @@ -27,7 +27,7 @@ class BlameResponse(BaseModel):
confidence_score: Optional[float] #: Float value between [0,1] indicating BLAME's confidence in the response where 0.0 represents the minimum confidence and 1.0 represents maximum.
birdviews: Optional[List[Image]] #: If `get_birdviews` was set, this contains the resulting image.

@validate_arguments
@validate_call
def blame(
location: str,
colliding_agents: Tuple[int, int],
Expand Down Expand Up @@ -136,7 +136,7 @@ def blame(
raise e


@validate_arguments
@validate_call
async def async_blame(
location: str,
colliding_agents: Tuple[int, int],
Expand Down
6 changes: 3 additions & 3 deletions invertedai/api/drive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from typing import List, Optional, Tuple
from pydantic import BaseModel, validate_arguments
from pydantic import BaseModel, validate_call
import asyncio

import invertedai as iai
Expand Down Expand Up @@ -48,7 +48,7 @@ class DriveResponse(BaseModel):
api_model_version: str # Model version used for this API call


@validate_arguments
@validate_call
def drive(
location: str,
agent_states: List[AgentState],
Expand Down Expand Up @@ -208,7 +208,7 @@ def _tolist(input_data: List):
raise e


@validate_arguments
@validate_call
async def async_drive(
location: str,
agent_states: List[AgentState],
Expand Down
6 changes: 3 additions & 3 deletions invertedai/api/initialize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from pydantic import BaseModel, validate_arguments
from pydantic import BaseModel, validate_call
from typing import List, Optional, Dict, Tuple
import asyncio

Expand Down Expand Up @@ -48,7 +48,7 @@ class InitializeResponse(BaseModel):
api_model_version: str # Model version used for this API call


@validate_arguments
@validate_call
def initialize(
location: str,
agent_attributes: Optional[List[AgentAttributes]] = None,
Expand Down Expand Up @@ -204,7 +204,7 @@ def initialize(
iai.logger.info(iai.logger.logfmt("Waiting for model to warm up", error=e))


@validate_arguments
@validate_call
async def async_initialize(
location: str,
agent_attributes: Optional[List[AgentAttributes]] = None,
Expand Down
4 changes: 2 additions & 2 deletions invertedai/api/light.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from typing import List, Optional, Dict
from pydantic import BaseModel, Field, validate_arguments
from pydantic import BaseModel, Field, validate_call
import invertedai as iai

from invertedai.api.config import TIMEOUT, should_use_mock_api
Expand All @@ -23,7 +23,7 @@ class LightResponse(BaseModel):
"`LIGHT`.",)


@validate_arguments
@validate_call
def light(
location: str,
recurrent_states: Optional[str] = None,
Expand Down
4 changes: 2 additions & 2 deletions invertedai/api/location.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from pydantic import BaseModel, validate_arguments
from pydantic import BaseModel, validate_call
from typing import Optional, List, Tuple

import invertedai as iai
Expand All @@ -26,7 +26,7 @@ class LocationResponse(BaseModel):
static_actors: List[StaticMapActor] #: Lists traffic lights with their IDs and locations.


@validate_arguments
@validate_call
def location_info(
location: str,
include_map_source: bool = False,
Expand Down
12 changes: 1 addition & 11 deletions invertedai/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import invertedai as iai
from invertedai.error import InvalidInputType, InvalidInput

RECURRENT_SIZE = 132
RECURRENT_SIZE = 152
TrafficLightId = int


Expand All @@ -18,16 +18,6 @@ class RecurrentState(BaseModel):

packed: List[float] = [0.0] * RECURRENT_SIZE

#: Internal representation of the recurrent state.

@model_validator(mode='before')
@classmethod
def check_recurrentstate(cls, values):
if len(values.get("packed")) == RECURRENT_SIZE:
return values
else:
raise InvalidInput("Incorrect Recurrentstate Size.")

@classmethod
def fromval(cls, val):
return cls(packed=val)
Expand Down
1 change: 0 additions & 1 deletion invertedai/cosimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import random
from collections import deque
from queue import Queue
from pydantic import BaseModel, validate_arguments
from itertools import product
import numpy as np
import asyncio
Expand Down
1 change: 1 addition & 0 deletions invertedai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self):
"Content-Type": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"Connection": "keep-alive",
"x-client-version": iai.__version__
}
)
self._base_url = self._get_base_url()
Expand Down
7 changes: 7 additions & 0 deletions invertedai_cpp/invertedai/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ cc_library(
deps = [
"//invertedai/externals:root-certificates",
"@boost//:beast",
":version",
],
)

Expand All @@ -121,3 +122,9 @@ cc_library(
":session",
],
)

cc_library(
name = "version",
hdrs = ["version.h"],
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions invertedai_cpp/invertedai/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <boost/iostreams/filtering_stream.hpp>

#include "externals/root_certificates.hpp"
#include "version.h"


namespace beast = boost::beast; // from <boost/beast.hpp>
namespace http = beast::http; // from <boost/beast/http.hpp>
Expand Down Expand Up @@ -98,6 +100,7 @@ const std::string Session::request(
req.set("Accept-Encoding", "gzip");
req.set("accept", "application/json");
req.set("x-api-key", this->api_key_);
req.set("x-client-version", INVERTEDAI_VERSION);
if (debug_mode) {
std::cout << "req body content:\n";
std::cout << body_str << std::endl;
Expand Down
1 change: 1 addition & 0 deletions invertedai_cpp/invertedai/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/ssl.hpp>
#include "version.h"

namespace beast = boost::beast; // from <boost/beast.hpp>
namespace net = boost::asio; // from <boost/asio.hpp>
Expand Down
7 changes: 7 additions & 0 deletions invertedai_cpp/invertedai/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// version.h
#ifndef INVERTEDAI_VERSION_H
#define INVERTEDAI_VERSION_H

#define INVERTEDAI_VERSION "0.0.15rc0"

#endif // INVERTEDAI_VERSION_H
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "invertedai"
version = "0.0.14"
version = "0.0.15rc0"
description = "Client SDK for InvertedAI"
authors = ["Inverted AI <info@inverted.ai>"]
readme = "README.md"
Expand Down

0 comments on commit 26fbd63

Please sign in to comment.