Skip to content

Commit

Permalink
Merge pull request #429 from binpash/future
Browse files Browse the repository at this point in the history
Merge future to main
  • Loading branch information
dkarnikis authored Dec 17, 2021
2 parents c178ef5 + 1ea0bb0 commit 7a26863
Show file tree
Hide file tree
Showing 101 changed files with 3,019 additions and 408 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/futureci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Pash-future-CI-issue
on:
# Run the for-loop tests when pushing to future or when creating a new PR
push:
branches:
- future
paths:
- compiler/**
- runtime/**
- evaluation/**
- annotations/**
pull_request:
branches:
- future
paths:
- compiler/**
- runtime/**
- evaluation/**
- annotations/**
jobs:
future-ci:
runs-on: ubuntu-latest
steps:

- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Trigger Future CI
run: |
echo "Slug variables"
base=${{ env.GITHUB_REF_SLUG }}
branch=${{ env.GITHUB_HEAD_REF_SLUG }}
hash=${{ env.GITHUB_SHA_SHORT }}
if [[ $branch == '' ]]; then
echo "We are pushing directly to future"
branch=$base
else
echo "We are doing a PR"
hash=${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}
fi
# construct the url for performance and correctness
tests="http://ctrl.pash.ndr.md/job=issue&branch=$branch&benchmark=TIGHT-LOOP&commit=$hash"
# issue the tests for the future branch
curl -s "$tests"
echo "$tests"
14 changes: 13 additions & 1 deletion annotations/cat.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@
"outputs": ["stdout"],
"comment": "Pure because -n prints line numbering, and splitting affects it"
},
{
"predicate":
{
"operator": "len_args_eq",
"operands": [0]
},
"comment": ":')",
"class": "stateless",
"inputs": ["stdin"],
"outputs": ["stdout"]
},
{
"predicate": "default",
"class": "stateless",
"inputs": ["args[:]"],
"outputs": ["stdout"]
"outputs": ["stdout"],
"options": ["stdin-hyphen"]
}
],
"options": ["stdin-hyphen"]
Expand Down
13 changes: 13 additions & 0 deletions annotations/convert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"command": "convert",
"cases":
[

{
"predicate": "default",
"class": "pure",
"inputs": ["args[1]"],
"outputs": ["args[2]"]
}
]
}
2 changes: 1 addition & 1 deletion annotations/diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[
{
"predicate": "default",
"class": "non-pure",
"class": "pure",
"inputs": ["args[:]"],
"outputs": ["stdout"]
}
Expand Down
2 changes: 1 addition & 1 deletion annotations/echo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"predicate": "default",
"class": "pure", "comment": "No input so f(a++b) != f(a) ++ f(b)",
"inputs": ["args[:]"],
"inputs": [ ],
"outputs": ["stdout"]
}
]
Expand Down
13 changes: 13 additions & 0 deletions annotations/ffmpeg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"command": "ffmpeg",
"cases":
[
{
"predicate": "default",
"class": "pure",
"inputs": ["args[:]"],
"outputs": ["stdout"],
"options": ["stdin-hyphen"]
}
]
}
12 changes: 12 additions & 0 deletions annotations/package_build_aux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"command": "package_build_aux",
"cases":
[
{
"predicate": "default",
"class": "pure",
"inputs": ["args[0]"],
"outputs": ["stdout"]
}
]
}
13 changes: 13 additions & 0 deletions annotations/process_bio_s_line.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"command": "process_bio_s_line",
"cases":
[
{
"predicate": "default",
"class": "pure",
"inputs": ["args[0]"],
"outputs": ["stdout"]
}
],
"comment": "Used in bio script."
}
13 changes: 13 additions & 0 deletions annotations/resize.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"command": "comm",
"cases":
[
{
"predicate": "default",
"class": "pure",
"inputs": ["args[:]"],
"outputs": ["stdout"],
"options": ["stdin-hyphen"]
}
]
}
12 changes: 12 additions & 0 deletions annotations/run_tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"command": "run_tests",
"cases":
[
{
"predicate": "default",
"class": "pure",
"inputs": ["args[0]"],
"outputs": ["stdout"]
}
]
}
2 changes: 1 addition & 1 deletion compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ The compiler is outlined in the [EuroSys paper](https://arxiv.org/pdf/2007.09436
* PaSh originally did not have a preprocessing component, and didn't handle variable expansion. It now does both, significantly improving its practical applicability since it can be used on scripts where the environment variables are modified throughout the script.

* PaSh originally was using code in [parser](./parser) -- a port of [libdash](https://github.com/mgree/), the `dash` parser extended with OCaml bindings -- and specifically the `ocaml2json` and `json2ocaml` binaries to interface with PaSh. PaSh now uses a custom parser written in Python, avoiding any dependency to OCaml and simplifying dependency management.

16 changes: 9 additions & 7 deletions compiler/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def args_redirs_from_io_list(io_list, fids, ann_options, args, redirs):
assert(len(rem_fids) == 0)
return args, redirs

## This function redirects an fid to stdout if it is not already stdout
def redirect_to_stdout_if_not_already(fid):
if (fid.has_file_descriptor_resource() and fid.resource.is_stdout()):
return []
else:
return [redir_stdout_to_file(fid.to_ast())]

## TODO: We need to handle args[:] followed by stdin by having a look-ahead.
## It might not be necessary actually. Since it is valid to have them all in
## args then.
Expand All @@ -85,13 +92,8 @@ def args_redirs_from_io_list_el(io, fids, ann_options, args, redirs):
elif(io == "stdout"):
fid = fids[0]
rem_fids = fids[1:]
## Do not redirect if it is for stdout
if (fid.has_file_descriptor_resource() and fid.resource.is_stdout()):
return args, redirs, rem_fids
else:
new_redirs = redirs
new_redirs.append(redir_stdout_to_file(fid.to_ast()))
return args, new_redirs, rem_fids
new_redirs = redirs + redirect_to_stdout_if_not_already(fid)
return args, new_redirs, rem_fids
else:
assert(io.startswith("args"))
indices = io.split("[")[1].split("]")[0]
Expand Down
Loading

0 comments on commit 7a26863

Please sign in to comment.