Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
Rule Engine Service
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
brooklyn
Rule Engine Service
Commits
16a3251a
Commit
16a3251a
authored
Oct 19, 2022
by
Sarah Abrishami
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: modifications
parent
033ecca1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
6 deletions
+37
-6
app/__init__.py
app/__init__.py
+7
-1
app/config.py
app/config.py
+1
-1
app/main/__init__.py
app/main/__init__.py
+2
-1
app/main/utils/common.py
app/main/utils/common.py
+19
-3
app/main/views/life_check.py
app/main/views/life_check.py
+8
-0
No files found.
app/__init__.py
View file @
16a3251a
...
@@ -4,9 +4,12 @@ import logging
...
@@ -4,9 +4,12 @@ import logging
from
logging.handlers
import
RotatingFileHandler
from
logging.handlers
import
RotatingFileHandler
from
flask
import
Flask
from
flask
import
Flask
from
flask_caching
import
Cache
from
flask_caching
import
Cache
from
flask_sqlalchemy
import
SQLAlchemy
# from flask_migrate import Migrate
from
apscheduler.schedulers.background
import
BackgroundScheduler
from
apscheduler.schedulers.background
import
BackgroundScheduler
from
app.config
import
configs
from
app.config
import
configs
db
=
SQLAlchemy
()
cache
=
Cache
()
cache
=
Cache
()
...
@@ -27,11 +30,14 @@ def create_app():
...
@@ -27,11 +30,14 @@ def create_app():
config_name
=
os
.
getenv
(
'FLASK_ENV'
)
or
'default'
config_name
=
os
.
getenv
(
'FLASK_ENV'
)
or
'default'
app
.
config
.
from_object
(
configs
[
config_name
])
app
.
config
.
from_object
(
configs
[
config_name
])
db
.
init_app
(
app
)
# migrate.init_app(app, db)
cache
.
init_app
(
app
)
cache
.
init_app
(
app
)
from
app.main
import
main
as
main_blueprint
from
app.main
import
main
as
main_blueprint
app
.
register_blueprint
(
main_blueprint
)
app
.
register_blueprint
(
main_blueprint
)
with
app
.
app_context
():
db
.
create_all
()
# if app.config['AUTO_UPDATE']:
# if app.config['AUTO_UPDATE']:
# sched = BackgroundScheduler(daemon=True)
# sched = BackgroundScheduler(daemon=True)
...
...
app/config.py
View file @
16a3251a
...
@@ -7,7 +7,7 @@ class Config:
...
@@ -7,7 +7,7 @@ class Config:
DEBUG
=
False
DEBUG
=
False
TESTING
=
False
TESTING
=
False
API_DESCRIPTION
=
'Broccoli Rule Engine'
API_DESCRIPTION
=
'Broccoli Rule Engine'
SQLALCHEMY_DATABASE_URI
=
'postgresql+psycopg2://postg
es:postg
es@10.1.1.5:5432/dqdb_test'
SQLALCHEMY_DATABASE_URI
=
'postgresql+psycopg2://postg
res:postgr
es@10.1.1.5:5432/dqdb_test'
SQLALCHEMY_TRACK_MODIFICATIONS
=
False
SQLALCHEMY_TRACK_MODIFICATIONS
=
False
LOG_TO_STDOUT
=
os
.
environ
.
get
(
'LOG_TO_STDOUT'
)
LOG_TO_STDOUT
=
os
.
environ
.
get
(
'LOG_TO_STDOUT'
)
PORT
=
5800
PORT
=
5800
...
...
app/main/__init__.py
View file @
16a3251a
...
@@ -6,4 +6,5 @@ main = Blueprint('main', __name__)
...
@@ -6,4 +6,5 @@ main = Blueprint('main', __name__)
CORS
(
main
)
CORS
(
main
)
from
app.main
import
errors
from
app.main
import
errors
from
app.main.views
import
life_check
from
app.main.views
import
life_check
,
validate
from
app
import
db
app/main/utils/common.py
View file @
16a3251a
import
gzip
import
gzip
import
collections
import
collections
from
flask
import
make_response
,
json
,
current_app
from
flask
import
make_response
,
json
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
import
khayyam
as
kym
from
app.errors
import
*
from
app.errors
import
*
import
gc
import
gc
import
requests
from
rulemall.utils.rule_builder
import
rule_builder
from
app
import
db
def
response_message
(
data
=
None
,
status
=
200
):
def
response_message
(
data
=
None
,
status
=
200
):
...
@@ -55,3 +55,19 @@ def convert(o):
...
@@ -55,3 +55,19 @@ def convert(o):
if
o
is
np
.
ma
.
masked
:
if
o
is
np
.
ma
.
masked
:
return
None
return
None
json
.
dumps
(
o
)
json
.
dumps
(
o
)
def
read_data
():
return
pd
.
read_excel
(
'app/main/static/sample_data.xlsx'
)
def
read_rules
():
return
rule_builder
(
'app/main/static/rule_config.yml'
)
def
write_validations
(
df
,
table_name
=
'test2'
):
try
:
df
.
to_sql
(
table_name
,
con
=
db
.
engine
,
if_exists
=
'replace'
,
index
=
False
)
except
Exception
as
e
:
return
str
(
e
)
return
'success'
app/main/views/life_check.py
View file @
16a3251a
from
app.main
import
main
from
app.main.utils.common
import
response_message
from
flask
import
current_app
@
main
.
route
(
'/'
,
methods
=
[
'GET'
,
'POST'
])
def
life_check
():
return
response_message
(
f
'{current_app.config["API_DESCRIPTION"]} API is active!'
)
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