Skip to content

Commit

Permalink
Fixed clingoexplaid, fixed test, added error message for operation
Browse files Browse the repository at this point in the history
  • Loading branch information
susuhahnml committed Aug 23, 2024
1 parent 5f00817 commit 3c5b7e0
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ requirements:
- uvicorn
- clingraph
- Pillow
- clingexplaid
- clingexplaid>=1.0.14

build:
number: {{ build }}
Expand Down
2 changes: 1 addition & 1 deletion .github/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ conda:
- uvicorn
- clingraph
- Pillow
- clingexplaid
- clingexplaid>=1.0.14

build:
noarch: python
Expand Down
2 changes: 1 addition & 1 deletion .github/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ networkx
uvicorn
clingraph
Pillow
clingexplaid
clingexplaid>=1.0.14
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* Attributes
* Attribute `visible` is now `visibility` and the values are either `shown` or `hidden`
* Attribute regarding style (such as `filter`) for canvas elements with an image path are now applied only to the canvas
* Components
* New component `progress_bar`
* Domain constructors
* added optimization information into domain state
* added information about externals
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"serverUrl": "http://localhost",
"serverPort": "8000"
}
{"serverPort": 8000, "serverUrl": "http://localhost"}
2 changes: 1 addition & 1 deletion clinguin/server/application/backends/clingo_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def _set_external(self, symbol, name):
f"Invalid external value {name}. Must be true, false or relase"
)

def _add_assumption(self, symbol, value: "true"):
def _add_assumption(self, symbol, value="true"):
"""
Adds an assumption to the list of assumptions.
Expand Down
8 changes: 4 additions & 4 deletions clinguin/server/presentation/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ async def operation_executor(self, backend_call_string: BackendOperationDto):
self._backend._set_context([])

function_name = symbol.name
policies = []
operations = []
if function_name == "":
policies = symbol.arguments
operations = symbol.arguments
else:
policies = [symbol]
operations = [symbol]

for p in policies:
for p in operations:
function_name = p.name

function_arguments = list(map(str, p.arguments))
Expand Down
12 changes: 11 additions & 1 deletion clinguin/server/presentation/endpoints_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def call_function(cls, backend, name, args, kwargs):
snake_case_name = name
camel_case_name = CaseConverter.snake_case_to_camel_case(snake_case_name)

public_functions = [
str(func) for func in dir(backend) if not func.startswith("_")
]
if snake_case_name.startswith("_"):
error_string = "Cannot call private functions '" + name + "' in backend."
logger.error(error_string)
logger.error("Available operations: \n\t%s", "\n\t".join(public_functions))
raise Exception(error_string)

if hasattr(backend, snake_case_name):
function = getattr(backend, snake_case_name)
found = True
Expand All @@ -38,6 +47,7 @@ def call_function(cls, backend, name, args, kwargs):
if found:
result = function(*args, **kwargs)
return result
error_string = "Could not find function '" + name + "' in backend."
error_string = "Could not find operation '" + name + "' in backend."
logger.error(error_string)
logger.error("Available operations: \n\t%s", "\n\t".join(public_functions))
raise Exception(error_string)
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ nbsphinx>=0.8.8
jinja2>=3.0.3
clingo-dl
furo
clingexplaid
clingexplaid>=1.0.14
sphinxemoji
myst_parser
11 changes: 1 addition & 10 deletions examples/test/test_07/ui.lp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,5 @@ elem(canvis(1), canvas, window).
attr(canvis(1), height, 500).
attr(canvis(1), width, 450).
attr(canvis(1), image, "examples/test/test_07/tommi.jpg").
attr(canvis(1), image, "examples/test/test_07/tommi.jpg").
attr(canvis(1), filter, "invert(1)").
when(canvis(1), click, update, (msg, visibility, shown)).

attr(canvis(1), resize, true).

elem(msg, message, window).
attr(msg, title, "Clicked").
attr(msg, visibility, "hidden").


attr(canvis(1), resize, true).
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install_requires =
uvicorn
clingraph
Pillow
clingexplaid
clingexplaid>=1.0.14


[options.package_data]
Expand Down
2 changes: 2 additions & 0 deletions tests/utils_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def assert_result(self, should_output, received_by_request):
received_by_request = json.loads(
json.dumps(received_by_request, default=lambda o: o.__dict__)
)
print("From request:")
print(received_by_request)
print("\nExpected request:")
print(should_output)
assert str(received_by_request) == str(should_output)

0 comments on commit 3c5b7e0

Please sign in to comment.