Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
5ed0a29b
Commit
5ed0a29b
authored
Oct 28, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed coroutines, db init
parent
f163f6e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
app.py
app.py
+7
-5
cosmos_client.py
utils/cosmos_client.py
+10
-2
No files found.
app.py
View file @
5ed0a29b
...
...
@@ -17,7 +17,8 @@ from botbuilder.core import (
from
botbuilder.schema
import
Activity
,
ActivityTypes
from
marshmallow
import
EXCLUDE
,
ValidationError
from
bots
import
TeamsMessagingExtensionsActionPreviewBot
from
bots.messaging_extension_action_preview_bot
import
\
TeamsMessagingExtensionsActionPreviewBot
from
bots.exceptions
import
ConversationNotFound
,
DataParsingError
from
config
import
AppConfig
,
COSMOS_CLIENT
,
TeamsAppConfig
,
TOKEN_HELPER
,
\
CosmosDBConfig
...
...
@@ -214,22 +215,23 @@ async def v1_auth(request: Request) -> Response:
async
def
init_db_containers
():
""" To speed up the process we have to create containers first """
COSMOS_CLIENT
.
create_container
(
await
COSMOS_CLIENT
.
create_db
(
CosmosDBConfig
.
Conversations
.
DATABASE
)
await
COSMOS_CLIENT
.
create_container
(
CosmosDBConfig
.
Conversations
.
DATABASE
,
CosmosDBConfig
.
Conversations
.
CONTAINER
,
CosmosDBConfig
.
Conversations
.
PARTITION_KEY
)
COSMOS_CLIENT
.
create_container
(
await
COSMOS_CLIENT
.
create_container
(
CosmosDBConfig
.
Notifications
.
DATABASE
,
CosmosDBConfig
.
Notifications
.
CONTAINER
,
CosmosDBConfig
.
Notifications
.
PARTITION_KEY
)
COSMOS_CLIENT
.
create_container
(
await
COSMOS_CLIENT
.
create_container
(
CosmosDBConfig
.
Acknowledges
.
DATABASE
,
CosmosDBConfig
.
Acknowledges
.
CONTAINER
,
CosmosDBConfig
.
Acknowledges
.
PARTITION_KEY
)
COSMOS_CLIENT
.
create_container
(
await
COSMOS_CLIENT
.
create_container
(
CosmosDBConfig
.
Initiations
.
DATABASE
,
CosmosDBConfig
.
Initiations
.
CONTAINER
,
CosmosDBConfig
.
Initiations
.
PARTITION_KEY
...
...
utils/cosmos_client.py
View file @
5ed0a29b
...
...
@@ -71,6 +71,14 @@ class CosmosClient:
def
bl
()
->
DatabaseProxy
:
""" Get Notifications container blocking """
return
self
.
client
.
get_database_client
(
database_id
)
return
await
self
.
execute_blocking
(
bl
)
async
def
create_db
(
self
,
database_id
:
str
)
->
DatabaseProxy
:
""" Create DB """
def
bl
()
->
DatabaseProxy
:
""" Get Notifications container blocking """
try
:
return
self
.
client
.
create_database
(
id
=
database_id
)
except
exceptions
.
CosmosResourceExistsError
:
...
...
@@ -88,8 +96,8 @@ class CosmosClient:
try
:
return
db
.
create_container
(
container_id
,
partition_key
,
**
kwargs
)
except
exceptions
.
CosmosResource
NotFound
Error
:
pass
except
exceptions
.
CosmosResource
Exists
Error
:
return
db
.
get_container_client
(
container_id
)
return
await
self
.
execute_blocking
(
bl
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment