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

Endpoint for counting objects in a gromet FN #557

Closed
Free-Quarks opened this issue Oct 6, 2023 · 4 comments · Fixed by #574
Closed

Endpoint for counting objects in a gromet FN #557

Free-Quarks opened this issue Oct 6, 2023 · 4 comments · Fixed by #574
Assignees
Labels
CI continuous integration and automated workflows enhancement New feature or request tests Issues related to existing or additional tests

Comments

@Free-Quarks
Copy link
Collaborator

Add some endpoints to count objects in a gromet FN to allow for easier testing and development of tests for the code2amr pipeline.

@Free-Quarks Free-Quarks added enhancement New feature or request tests Issues related to existing or additional tests CI continuous integration and automated workflows labels Oct 6, 2023
@vincentraymond-ua
Copy link
Contributor

@Free-Quarks - I'm working on creating an endpoint for this. Below is an example output I'm generating. Do you think these fields are adequate, or are there any additional fields you would want to add?

{'b': 7, 'bf': 9, 'opi': 1, 'opo': 3, 'pil': 0, 'pol': 0, 'wlopi': 0, 'wll': 0, 'wlf': 0, 'wlc': 0, 'wlopo': 0, 'pof': 7, 'pif': 3, 'wfopi': 1, 'wfl': 0, 'wff': 2, 'wfc': 0, 'wfopo': 3, 'pic': 0, 'poc': 0, 'wcopi': 0, 'wcl': 0, 'wcf': 0, 'wcc': 0, 'wcopo': 0}

@Free-Quarks
Copy link
Collaborator Author

Those look great! The only other possible field that came to mind, which is minor and not super necessary, would be if we could also have a field for an aggregate count of all the wires (just adding all the wiring fields together), since they aren't distinguished in the memgraph.

@vincentraymond-ua
Copy link
Contributor

Update 10/10/2023

This is essentially complete, I just need to finish writing the unit test for the endpoint.

@vincentraymond-ua
Copy link
Contributor

Update 10/13/2023

To be resolved by #574

vincentraymond-ua added a commit that referenced this issue Oct 13, 2023
## Adding gromet-object-count endpoint
Adds an additional endpoint `gromet-object-count` to code2fn REST API.
The endpoint accepts a Gromet dictionary (the response type from
fn-given-filepaths and fn-given-filepaths-zip) and returns a dictionary
with the counts of each Gromet object. It also contain aggregate values
for the number of boxes, ports, and wires.

### Example Call
``` Python
system = {
      "files": ["example1.py", "dir/example2.py"],
      "blobs": [
          "greet = lambda: print('howdy!')\ngreet()",
          "#Variable declaration\nx=2\n#Function definition\ndef foo(x):\n    '''Increment the input variable'''\n    return x+1",  # Content of dir/example2.py
      ],
  }
  response = client.post("/code2fn/fn-given-filepaths", json=system)
  gromet_collection = response.json()
  response = client.post("/code2fn/gromet-object-count", json=gromet_collection)
```

### Example Output
``` Python
{'boxes': 14, 'ports': 6 , 'wires': 14 'b': 7, 'bf': 9, 'opi': 1, 'opo': 3, 'pil': 0, 'pol': 0, 'wlopi': 0, 'wll': 0, 'wlf': 0, 'wlc': 0, 'wlopo': 0, 'pof': 7, 'pif': 3, 'wfopi': 1, 'wfl': 0, 'wff': 2, 'wfc': 0, 'wfopo': 3, 'pic': 0, 'poc': 0, 'wcopi': 0, 'wcl': 0, 'wcf': 0, 'wcc': 0, 'wcopo': 0}
```

### Additional changes
Adds a test_gromet_object_count function for CI unit testing

Resolves #557
github-actions bot added a commit that referenced this issue Oct 13, 2023
## Adding gromet-object-count endpoint
Adds an additional endpoint `gromet-object-count` to code2fn REST API.
The endpoint accepts a Gromet dictionary (the response type from
fn-given-filepaths and fn-given-filepaths-zip) and returns a dictionary
with the counts of each Gromet object. It also contain aggregate values
for the number of boxes, ports, and wires.

### Example Call
``` Python
system = {
      "files": ["example1.py", "dir/example2.py"],
      "blobs": [
          "greet = lambda: print('howdy!')\ngreet()",
          "#Variable declaration\nx=2\n#Function definition\ndef foo(x):\n    '''Increment the input variable'''\n    return x+1",  # Content of dir/example2.py
      ],
  }
  response = client.post("/code2fn/fn-given-filepaths", json=system)
  gromet_collection = response.json()
  response = client.post("/code2fn/gromet-object-count", json=gromet_collection)
```

### Example Output
``` Python
{'boxes': 14, 'ports': 6 , 'wires': 14 'b': 7, 'bf': 9, 'opi': 1, 'opo': 3, 'pil': 0, 'pol': 0, 'wlopi': 0, 'wll': 0, 'wlf': 0, 'wlc': 0, 'wlopo': 0, 'pof': 7, 'pif': 3, 'wfopi': 1, 'wfl': 0, 'wff': 2, 'wfc': 0, 'wfopo': 3, 'pic': 0, 'poc': 0, 'wcopi': 0, 'wcl': 0, 'wcf': 0, 'wcc': 0, 'wcopo': 0}
```

### Additional changes
Adds a test_gromet_object_count function for CI unit testing

Resolves #557 386494b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI continuous integration and automated workflows enhancement New feature or request tests Issues related to existing or additional tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants