Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Bundle Block works in test harness, but does not work in Type Refinery #537

Open
6 tasks
brettforbes opened this issue Aug 12, 2023 · 0 comments
Open
6 tasks

Comments

@brettforbes
Copy link

Prerequisites - Installing the layout in TypeRefinery

The final layout with two new block definitions at the bottom of the palette on the left (underlined in yellow)
image

As a prerequisite open TypeRefinery with a default project, one must have your local copy of the brett_blocks repo open in an IDE, and a TypeRefinery worksheet based on the default project (custom Connection blocks cannot connect to a custom Connection object, so a hack is used)

  1. Create a new Send Data Trigger: Drag a Send Data trigger block to the canvas
  2. Create a new URL block: Drag a green Code block to the canvas. Richt-click the block and select Edit. Separately, copy the contents of the ui_code,html, replace all of the existing code inside the Edit code window, and press submit. Delete the block you were working on and check the pallete, and there is a new URL block there, drag it and drop it to the canvase. Finally, right-click the new URL object and select Configure, copy the contents of javascript code file and replace the existing javascript code in the Code block, and press the Apply button
  3. Create a New Connection Block: Drag a API Datastore Connection" block onto the canvas, right click it and ensure the correct datastore is selected
  4. Create a new StixORM Import Bundle Block: Drag a "Run (Nodes and Edges)" block onto the canvas, right-click on the object and select Edit. Separately, copy the contents of the ui_code.html file, and then replace all of the existing code. Press the Submit button, and a new block will appear on the palette. Drag on a new StixORM Import Bundle block from the palette on the left, right-click it and select Configure. Separately copy the contents of the script.py file and replace the current block code. Open the config,json file, and ensure your Requirements field matches the contents in the file.
  5. Finally, drag on a Print and a Print JSON block. Connect the blocks so that
  • Send Data -> Connection
  • Send Data -> URL
  • URL -> StixORM.URL
  • Connection -> StixORM.Connection
  • URL -> Print
  • StixORM.output -> Print (JSON)
  1. Press the Run Button on the Send Data block, and the process will fail, In fact, the StixORM block reacts far more quickly and fails, than the block does in its test harness, where the request(url) takes some time before it succeeds

Expected Behavior

The Expected Behaviour can be demonstrated by the test harness, in the local brett_blocks repo, assuming Poetry was used to install all of the dependencies. Ensuring that a copy of TypeRefinery is running locally on localhost, port 1729. Then running the method try_import_bundle(), pauses for a few second to make the https call, and then writes out an output.json file in the root, where the standard TypeDB ORM Result Object List format (an object-by-object list) shows the Python function works perfectly

Current Behavior

Running that same code, and the block does not wait for the requests library to get a response, and instead fails with the following json output, instead of the Results List format that was expected.

{ "error":"false" "script.name":"req-1691818469.520285.99984.py" "script":"C:\Users\brett\AppData\Roaming\TypeRefinery\services\fastapi\generated\algorithm\req-1691818469.520285.99984.py" "script.exists":"True" "script.url":"/algorithm/req-1691818469.520285.99984.py/script" "output":"C:\Users\brett\AppData\Roaming\TypeRefinery\services\fastapi\generated\algorithm\req-1691818469.520285.99984.py.output" "output.exists":"False" "output.url":"/algorithm/req-1691818469.520285.99984.py/output" "log":"C:\Users\brett\AppData\Roaming\TypeRefinery\services\fastapi\generated\algorithm\req-1691818469.520285.99984.py.log" "log.exists":"True" "log.url":"/algorithm/req-1691818469.520285.99984.py/log" "return.output":"output" "Access-Control-Expose-Headers":"output.url,output.exists,output" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant