Skip to content

Commit

Permalink
21844: Updates load, clone, store, and verify methods to reflect Amal…
Browse files Browse the repository at this point in the history
…gam changes (#331)

Co-authored-by: Cade Mack <[email protected]>
Co-authored-by: howsoRes <[email protected]>
Co-authored-by: Andrew Bassett <[email protected]>
  • Loading branch information
4 people authored Oct 17, 2024
1 parent e5e7f95 commit f2bf0f3
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 15 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ Howso Engine. This extension supports debugging Amalgam scripts as well as trace
by [amalgam-lang-py](https://github.com/howsoai/amalgam-lang-py). Please see these projects to
get further information about debugging Amalgam.


### Tracefiles
If using the Howso Engine through the Python API, [howso-engine-py](https://github.com/howsoai/howso-engine-py),
you may be producing tracefiles through the Python API for Amalgam, [amalgam-lang-py](https://github.com/howsoai/amalgam-lang-py).
To use these tracefiles to debug the Amalgam code of the Howso Engine, the tracefile must be edited to load the Amalgam
files rather than the compressed Amalgam (.caml) files commonly used in the Python packages. We provide a utility Amalgam script,
`prep_tracefile.amlg` in the "utilities" directory which when run with Amalgam and the path to a tracefile specified as an argument,
will edit the tracefile accordingly to load `howso.amlg` from the current directory and make a necessary adjustment to the `LOAD_ENTITY`
call.

## Testing

The Howso Engine has a suite of unit tests and performance tests. To run the full set of unit tests, simply
Expand Down
8 changes: 7 additions & 1 deletion deploy_howso.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@


;don't load escaped filenames
(load_entity "./howso.amlg" "howso" (false) (false))
(load_entity
"./howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize_for_deployment" (assoc file_extension (get_value extension) ))

(if (= (null) (call_entity "howso" "debug_label" (assoc label "!parameterValidationMap")))
Expand Down
17 changes: 15 additions & 2 deletions howso/hierarchy.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@
(assign (assoc trainee_path (append !traineeContainer trainee) ))

(declare (assoc
result (load_entity (concat (or filepath (retrieve_from_entity "filepath")) !trainee_template_filename "." !file_extension) trainee_path (false) (false))
result
(load_entity
(concat (or filepath (retrieve_from_entity "filepath")) !trainee_template_filename "." !file_extension)
trainee_path
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
))

(if (!= (null) result)
Expand Down Expand Up @@ -388,7 +395,13 @@
;destroy the previously existing trainee
(destroy_entities trainee_path)
;attempt to load the entity into the specified path
(load_entity (concat filepath filename "." !file_extension) trainee_path (true))
(load_entity
(concat filepath filename "." !file_extension)
trainee_path
(null)
(false)
{escape_resource_name (true) escape_contained_resource_names (true)}
)
)
)
))
Expand Down
9 changes: 8 additions & 1 deletion howso/upgrade.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@

;create a temporary subtrainee from the latest howso code
(declare (assoc
new_trainee_path (load_entity (concat root_filepath !trainee_template_filename "." !file_extension) [!traineeContainer] (false) (false))
new_trainee_path
(load_entity
(concat root_filepath !trainee_template_filename "." !file_extension)
[!traineeContainer]
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
))

(if (= (null) new_trainee_path)
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/adult_test.amlg
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
(seq
#howso (null)
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/asteroid_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/bank_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/e_shop_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/mnist_10k_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/online_retail_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/range_queries_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion performance_tests/religious_texts_test.amlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
(seq
(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(call_entity "howso" "initialize" (assoc trainee_id "model"))

(declare (assoc test_start (system_time)))
Expand Down
8 changes: 7 additions & 1 deletion unit_tests/unit_test_howso.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
;howso engine should be located one directory up from unit tests
;TODO: pull path of test from argv, and auto-set howso path to be one directory up relative to the test

(load_entity "../howso.amlg" "howso" (false) (false))
(load_entity
"../howso.amlg"
"howso"
(null)
(false)
{escape_resource_name (false) escape_contained_resource_names (false)}
)
(assign_to_entities "howso" (assoc filepath "../"))
(call_entity "howso" "initialize" (assoc trainee_id "model"))

Expand Down
2 changes: 1 addition & 1 deletion utilities/export_trainee.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
))
)

(load_entity (concat howso_filepath "howso.caml" "howso")
(load_entity (concat howso_filepath "howso.caml") "howso")
(set_entity_root_permission "howso" 1)

(call_entity "howso" "export_trainee" (assoc
Expand Down
42 changes: 42 additions & 0 deletions utilities/prep_tracefile.amlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(seq
(declare (assoc
filepath (get argv 1)
))

(declare (assoc
original_file_content (load filepath)
))

;change load entity to load the amlg file and add escaping flag
(declare (assoc
modified_file_content
(substr
original_file_content
;search pattern
"LOAD_ENTITY (.+) \"(.+)howso.caml\" \"\" false \"\""
(null)
;replacement pattern
"LOAD_ENTITY $1 \"howso.amlg\" \"\" false \"{\\\"escape_contained_resource_names\\\": false}\""
)
))

;change the specified filepaths be the current directory
(assign (assoc
modified_file_content
(substr
modified_file_content
;search pattern
"\"filepath\": \".+/\""
(null)
;replacement pattern
"\"filepath\": \"\""
)
))

(print
(if (store filepath modified_file_content)
"Tracefile updated successfully."
"ERROR: Tracefile not updated successfully."
)
)
)
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "0.0.0",
"dependencies": {
"amalgam": "54.7.1"
"amalgam": "55.0.0"
}
}

0 comments on commit f2bf0f3

Please sign in to comment.