Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-computing-msc-ai-examples
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
Service Desk
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
Sebastian Rieger
cloud-computing-msc-ai-examples
Commits
05d363ca
You need to sign in or sign up before continuing.
Commit
05d363ca
authored
1 year ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
removed anyjson, refactoring based on pylint recommendations
parent
df64887c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
faafo/faafo/api/service.py
+8
-8
8 additions, 8 deletions
faafo/faafo/api/service.py
faafo/faafo/worker/service.py
+8
-5
8 additions, 5 deletions
faafo/faafo/worker/service.py
faafo/requirements.txt
+1
-1
1 addition, 1 deletion
faafo/requirements.txt
with
17 additions
and
14 deletions
faafo/faafo/api/service.py
+
8
−
8
View file @
05d363ca
...
...
@@ -112,7 +112,7 @@ connection = Connection(CONF.transport_url)
def
index
(
page
=
1
):
hostname
=
socket
.
gethostname
()
fractals
=
Fractal
.
query
.
filter
(
(
Fractal
.
checksum
!=
None
)
&
(
Fractal
.
size
!=
None
)).
paginate
(
(
Fractal
.
checksum
is
not
None
)
&
(
Fractal
.
size
is
not
None
)).
paginate
(
page
=
page
,
per_page
=
5
)
return
flask
.
render_template
(
'
index.html
'
,
fractals
=
fractals
,
hostname
=
hostname
)
...
...
@@ -137,7 +137,7 @@ def get_fractal(fractalid):
def
generate_fractal
(
**
kwargs
):
print
(
"
Postprocessor called!
"
+
str
(
kwargs
))
LOG
.
debug
(
"
Postprocessor called!
"
+
str
(
kwargs
))
with
producers
[
connection
].
acquire
(
block
=
True
)
as
producer
:
producer
.
publish
(
kwargs
[
'
result
'
],
serializer
=
'
json
'
,
...
...
@@ -145,13 +145,14 @@ def generate_fractal(**kwargs):
declare
=
[
queues
.
task_exchange
],
routing_key
=
'
normal
'
)
def
convert_image_to_binary
(
**
kwargs
):
print
(
"
Preprocessor call:
"
+
str
(
kwargs
))
LOG
.
debug
(
"
Preprocessor call:
"
+
str
(
kwargs
))
if
'
image
'
in
kwargs
[
'
data
'
][
'
data
'
][
'
attributes
'
]:
print
(
"
Converting image to binary...
"
)
kwargs
[
'
data
'
][
'
data
'
][
'
attributes
'
][
'
image
'
]
=
str
(
kwargs
[
'
data
'
][
'
data
'
][
'
attributes
'
][
'
image
'
]).
encode
(
"
ascii
"
)
#print("Preprocessor called!" + str(kwargs)
)
#return kwargs
LOG
.
debug
(
"
Converting image to binary...
"
)
kwargs
[
'
data
'
][
'
data
'
][
'
attributes
'
][
'
image
'
]
=
\
str
(
kwargs
[
'
data
'
][
'
data
'
][
'
attributes
'
][
'
image
'
]).
encode
(
"
ascii
"
)
def
main
():
print
(
"
Starting API server - new...
"
)
...
...
@@ -163,4 +164,3 @@ def main():
url_prefix
=
'
/v1
'
,
allow_client_generated_ids
=
True
)
app
.
run
(
host
=
CONF
.
listen_address
,
port
=
CONF
.
bind_port
,
debug
=
True
)
This diff is collapsed.
Click to expand it.
faafo/faafo/worker/service.py
+
8
−
5
View file @
05d363ca
...
...
@@ -19,12 +19,13 @@ import copy
import
hashlib
import
json
import
os
from
PIL
import
Image
import
random
import
socket
import
tempfile
import
time
from
PIL
import
Image
from
kombu.mixins
import
ConsumerMixin
from
oslo_config
import
cfg
from
oslo_log
import
log
...
...
@@ -152,11 +153,13 @@ class Worker(ConsumerMixin):
}
headers
=
{
'
Content-Type
'
:
'
application/vnd.api+json
'
,
'
Accept
'
:
'
application/vnd.api+json
'
}
'
Accept
'
:
'
application/vnd.api+json
'
}
resp
=
requests
.
patch
(
"
%s/v1/fractal/%s
"
%
(
CONF
.
endpoint_url
,
str
(
task
[
'
uuid
'
])),
json
.
dumps
(
result
),
headers
=
headers
)
(
CONF
.
endpoint_url
,
str
(
task
[
'
uuid
'
])),
json
.
dumps
(
result
),
headers
=
headers
,
timeout
=
30
)
LOG
.
debug
(
"
Result: %s
"
%
resp
.
text
)
message
.
ack
()
...
...
This diff is collapsed.
Click to expand it.
faafo/requirements.txt
+
1
−
1
View file @
05d363ca
...
...
@@ -4,7 +4,7 @@ pytz
positional
iso8601
#anyjson>=0.3.3
anyjson
#
anyjson
#eventlet>=0.17.4
eventlet
#PyMySQL>=0.6.2,<0.7 # 0.7 design change breaks faafo, MIT License
...
...
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