Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fractalis
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fractalis
fractalis
Commits
fb3abf46
There was a problem fetching the pipeline metadata.
Commit
fb3abf46
authored
8 years ago
by
Sascha Herzinger
Browse files
Options
Downloads
Patches
Plain Diff
added redislite
parent
3cd18e30
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fractalis/config.py
+12
-5
12 additions, 5 deletions
fractalis/config.py
setup.py
+2
-1
2 additions, 1 deletion
setup.py
tests/test_celery.py
+12
-13
12 additions, 13 deletions
tests/test_celery.py
with
26 additions
and
19 deletions
fractalis/config.py
+
12
−
5
View file @
fb3abf46
...
...
@@ -5,13 +5,17 @@ Exports:
"""
import
os
from
redislite
import
Redis
class
BaseConfig
(
object
):
"""
Basic configuration that should be used in production.
"""
DEBUG
=
False
TESTING
=
False
CELERY_BROKER_URL
=
'
redis://localhost:6379
'
CELERY_RESULT_BACKEND
=
'
redis://localhost:6379
'
REDIS_DB_PATH
=
os
.
path
.
join
(
os
.
sep
,
'
tmp
'
,
'
fractalis.db
'
)
rdb
=
Redis
(
REDIS_DB_PATH
)
CELERY_BROKER_URL
=
'
redis+socket://{}
'
.
format
(
rdb
.
socket_file
)
CELERY_RESULT_BACKEND
=
CELERY_BROKER_URL
class
DevelopmentConfig
(
BaseConfig
):
...
...
@@ -33,7 +37,7 @@ config = {
}
def
configure_app
(
app
):
def
configure_app
(
app
,
mode
=
None
):
"""
Apply configuration to given flask app based on environment variable.
This function assumes that the environment variable FRACTALIS_MODE contains
...
...
@@ -41,13 +45,16 @@ def configure_app(app):
it defaults to
'
production
'
. Each of these keys maps to a class in this
module that contains appropriate settings.
Arguments:
Keyword
Arguments:
app (Flask) -- An instance of the app to configure
mode (string) -- (optional) Use this instead of the environment variable
Exceptions:
KeyError (Exception) -- Is raised when FRACTALIS_MODE contains unknown key
"""
mode
=
os
.
getenv
(
'
FRACTALIS_MODE
'
,
default
=
'
production
'
)
if
mode
is
None
:
mode
=
os
.
getenv
(
'
FRACTALIS_MODE
'
,
default
=
'
production
'
)
try
:
app
.
config
.
from_object
(
config
[
mode
])
except
KeyError
as
e
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
2
−
1
View file @
fb3abf46
...
...
@@ -8,7 +8,8 @@ setup(
packages
=
find_packages
(),
install_requires
=
[
'
Flask
'
,
'
celery
'
'
celery
'
,
'
redislite
'
],
setup_requires
=
[
'
pytest-runner
'
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_celery.py
+
12
−
13
View file @
fb3abf46
import
pytest
from
celery
import
Celery
from
fractalis
import
celery
from
fractalis
.celery
import
init_
celery
class
TestCelery
(
object
):
@pytest.fixture
def
flask_
app
(
self
):
def
app
(
self
):
from
flask
import
Flask
from
fractalis.config
import
configure_app
app
=
Flask
(
'
test_app
'
)
app
.
config
[
'
TESTING
'
]
=
True
app
.
config
[
'
CELERY_BROKER_URL
'
]
=
'
redis://localhost:6379
'
app
.
config
[
'
CELERY_RESULT_BACKEND
'
]
=
'
redis://localhost:6379
'
configure_app
(
app
,
mode
=
'
testing
'
)
return
app
def
test_exception_if_no_connection_to_broker
(
self
,
flask_
app
):
flask_
app
.
config
[
'
CELERY_BROKER_URL
'
]
=
'
foobar
'
def
test_exception_if_no_connection_to_broker
(
self
,
app
):
app
.
config
[
'
CELERY_BROKER_URL
'
]
=
'
redis+socket:///foobar.socket
'
with
pytest
.
raises
(
ConnectionRefusedError
):
celery
.
init_celery
(
flask_
app
)
init_celery
(
app
)
def
test_exception_if_no_connection_to_result_backend
(
self
,
flask_
app
):
flask_
app
.
config
[
'
CELERY_RESULT_BACKEND
'
]
=
'
foobar
'
def
test_exception_if_no_connection_to_result_backend
(
self
,
app
):
app
.
config
[
'
CELERY_RESULT_BACKEND
'
]
=
'
redis+socket:///foobar.socket
'
with
pytest
.
raises
(
ConnectionRefusedError
):
celery
.
init_celery
(
flask_
app
)
init_celery
(
app
)
def
test_returns_celery_instance_if_connection_valid
(
self
,
flask_
app
):
celery_instance
=
celery
.
init_celery
(
flask_
app
)
def
test_returns_celery_instance_if_connection_valid
(
self
,
app
):
celery_instance
=
init_celery
(
app
)
assert
isinstance
(
celery_instance
,
Celery
)
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