Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MCC APSIS
NACSOS
NACSOS Core
Commits
08b81999
Commit
08b81999
authored
1 year ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
fix flake and mypy
parent
7a00bc19
No related branches found
No related tags found
1 merge request
!53
OpenAlex Search and pydantic v2 migration
Pipeline
#1840
failed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/api/routes/events.py
+1
-1
1 addition, 1 deletion
server/api/routes/events.py
server/util/config.py
+10
-3
10 additions, 3 deletions
server/util/config.py
server/util/middlewares.py
+1
-1
1 addition, 1 deletion
server/util/middlewares.py
with
12 additions
and
5 deletions
server/api/routes/events.py
+
1
−
1
View file @
08b81999
...
...
@@ -38,7 +38,7 @@ async def emit(event: Event) -> None:
emit_event
=
emit_event_type
.
model_validate
(
event
.
payload
)
logger
.
debug
(
f
'
Going to emit
{
emit_event
}
(
{
emit_event
}
)
'
)
await
eventbus
.
emit_async
(
emit_event
.
_
name
,
emit_event
)
# noqa PyProtectedMember
await
eventbus
.
emit_async
(
emit_event
.
name
,
emit_event
)
# noqa PyProtectedMember
# TODO user-configurable triggers (e.g. trigger on event or cron-like)
# - create schema, model, crud in nacsos-data (probably could just be a JSONB field in `Project`
...
...
This diff is collapsed.
Click to expand it.
server/util/config.py
+
10
−
3
View file @
08b81999
...
...
@@ -41,7 +41,7 @@ class ServerConfig(BaseModel):
return
[
i
.
strip
()
for
i
in
v
.
split
(
'
,
'
)]
if
isinstance
(
v
,
str
)
and
v
.
startswith
(
'
[
'
):
ret
=
json
.
loads
(
v
)
if
type
(
ret
)
==
list
:
if
type
(
ret
)
is
list
:
return
ret
elif
isinstance
(
v
,
(
list
,
str
)):
return
v
...
...
@@ -50,6 +50,7 @@ class ServerConfig(BaseModel):
class
DatabaseConfig
(
BaseModel
):
SCHEME
:
str
=
'
postgresql
'
SCHEMA
:
str
=
'
public
'
HOST
:
str
=
'
localhost
'
# host of the db server
PORT
:
int
=
5432
# port of the db server
USER
:
str
=
'
nacsos
'
# username for the database
...
...
@@ -113,13 +114,19 @@ class PipelinesConfig(BaseModel):
class
Settings
(
BaseSettings
):
# Basic server hosting settings
SERVER
:
ServerConfig
=
ServerConfig
()
# Database connection to main database
DB
:
DatabaseConfig
=
DatabaseConfig
()
# Global user account settings
USERS
:
UsersConfig
=
UsersConfig
()
# Settings for the nacsos-pipelines API
PIPES
:
PipelinesConfig
=
PipelinesConfig
()
# OpenAlex in PostgreSQL
OA_DB
:
DatabaseConfig
=
DatabaseConfig
()
# URL including path to OpenAlex collection
O
PENALEX
:
AnyHttpUrl
=
'
http://localhost:8983/solr/openalex
'
O
A_SOLR
:
AnyHttpUrl
=
'
http://localhost:8983/solr/openalex
'
# type: ignore[assignment]
# EMAIL: EmailConfig
...
...
@@ -137,7 +144,7 @@ class Settings(BaseSettings):
if
filename
is
not
None
:
with
open
(
filename
,
'
r
'
)
as
f
:
ret
=
toml
.
loads
(
f
.
read
())
if
type
(
ret
)
==
dict
:
if
type
(
ret
)
is
dict
:
return
ret
raise
ValueError
(
'
Logging config invalid!
'
)
...
...
This diff is collapsed.
Click to expand it.
server/util/middlewares.py
+
1
−
1
View file @
08b81999
...
...
@@ -47,7 +47,7 @@ class ErrorHandlingMiddleware(BaseHTTPMiddleware):
def
_resolve_status
(
cls
,
ew
:
Error
)
->
int
:
if
hasattr
(
ew
,
'
status
'
):
error_status
=
getattr
(
ew
,
'
status
'
)
if
type
(
error_status
)
==
int
:
if
type
(
error_status
)
is
int
:
return
error_status
return
http_status
.
HTTP_400_BAD_REQUEST
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment