{"id":15285850,"url":"https://github.com/joergen7/effi","last_synced_at":"2025-07-13T21:07:06.003Z","repository":{"id":57493739,"uuid":"44799234","full_name":"joergen7/effi","owner":"joergen7","description":"Erlang foreign function interface.","archived":false,"fork":false,"pushed_at":"2025-02-07T08:31:54.000Z","size":299,"stargazers_count":24,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-17T17:03:35.144Z","etag":null,"topics":["bash","erlang","ffi","matlab","octave","otp","python"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/effi","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joergen7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-23T08:00:58.000Z","updated_at":"2025-02-07T08:31:58.000Z","dependencies_parsed_at":"2025-03-17T08:21:18.994Z","dependency_job_id":null,"html_url":"https://github.com/joergen7/effi","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/joergen7/effi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Feffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Feffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Feffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Feffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joergen7","download_url":"https://codeload.github.com/joergen7/effi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Feffi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260406244,"owners_count":23004120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","erlang","ffi","matlab","octave","otp","python"],"created_at":"2024-09-30T15:07:52.259Z","updated_at":"2025-06-30T21:07:20.663Z","avatar_url":"https://github.com/joergen7.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Effi\n###### Erlang foreign function interface\n\n[![hex.pm](https://img.shields.io/hexpm/v/effi.svg?style=flat-square)](https://hex.pm/packages/effi)\n\nThe Erlang foreign function interface (Effi) is a way to run code in arbitrary foreign languages, e.g., Python or Octave from a native (Erlang) environment.\n\nHerein, the foreign code is executed in an environment that binds a defined set of input variables to values defined from the outside. After completion of the foreign code, a set of output variables is expected to be bound to values.\n\nThe foreign code snippet along with input variable bindings is given to effi in the form of a key-value map in a format that can easily be decoded/encoded using the [jsone](https://github.com/sile/jsone) JSON serialization library. Accordingly, effi comes with a command-line application that reads and writes JSON files.\n\n## Supported Languages\n\nThe following programming languages are supported by effi:\n\n- [Awk](https://www.gnu.org/software/gawk/manual/gawk.html)\n- [Bash](https://www.gnu.org/software/bash/)\n- [Elixir](https://elixir-lang.org/)\n- [Erlang](http://www.erlang.org/)\n- [gnuplot](http://www.gnuplot.info/)\n- [Java](https://www.java.com)\n- [Javascript](https://www.w3schools.com/js/)\n- [Matlab](https://www.mathworks.com/products/matlab.html)\n- [Octave](https://www.gnu.org/software/octave/)\n- [Perl](https://www.perl.org/)\n- [Python](https://www.python.org/)\n- [R](https://www.r-project.org/)\n- [Racket](http://www.racket-lang.org/)\n- [Wal](https://wal-lang.org/)\n\n## Integration and Build\n\n### Adding Effi to a Project\n\nAlthough Effi can be imported also directly from GitHub, we recommend adding a dependency via [hex.pm](https://hex.pm). Here, we show how this can be done using the build tools [rebar3](https://www.rebar3.org) or mix.\n\n\n#### rebar3\n\nTo integrate Effi into a rebar3-managed project change the `deps` entry in your application's `rebar.config` file to include the tuple `{effi, \"0.1.8\"}`.\n\n```erlang\n{deps, [{effi, \"0.1.8\"}]}.\n```\n\n\n#### mix\n\nTo integrate effi into a mix-managed project include the following\n\n```elixir\n{:effi, \"~\u003e 0.1.8\"}\n```\n\n### Compiling\n\nHaving rebar3 available on your system, compile as an Erlang project by entering\n\n    rebar3 compile\n\nIf you want to drive the project from the command line please compile it by entering\n\n    rebar3 escriptize\n\n### Building the Documentation\n\n    rebar3 edoc\n\n## Command Line Synopsis\n\nCompiling Effi using `escriptize` creates an Erlang script file `effi` whcih allows starting it via the command line.\n\nTo display a help text enter\n\n    ./effi --help\n\nThis shows the command line synopsis, which looks like the following:\n\n       ._,,,,  ,,_,=_\n        W   `_@__#__     The Erlang Foreign Function Interface (Effi) allows the\n       @P+#   F @F @     execution of functions defined in different programming\n      _W   y @  # qF     languages (e.g., Bash, Python, or R) by specifying the\n      ^^^^^  P qF  `     function's arguments, body and output values.\n\n    Copyright 2015 Jorgen Brandt \u003cjoergen@cuneiform-lang.org\u003e\n\n    Usage: effi [-v] [-h] [-d [\u003cdir\u003e]] [-i \u003cinput_file\u003e] [-o \u003coutput_file\u003e]\n\n      -v, --version      Show effi version.\n      -h, --help         Show command line options.\n      -d, --dir          Working directory in which to look for input data and \n                         run the request. [default: .]\n      -i, --input_file   Input file holding the effi request (must be \n                         specified).\n      -o, --output_file  Output file into which to write the effi reply (must \n                         be specified).\n\n\n    The input_file and output_file arguments must be specified.\n\nTo start Effi from the command line consuming the request file `effi_request.json` and let it produce the reply file `effi_reply.json` enter\n\n    ./effi -i effi_request.json -o effi_reply.json\n\nThe format of the request and reply is described below.\n\n## Erlang API\n\nEffi can be driven from an Erlang API by using the function `effi:handle_request/2`. Given an Erlang hash map using atoms as keys and binaries as values bound in the variable `EffiRequest` you can start effi by entering\n\n```erlang\nEffiRequest = #{ ... }.\nDir = \"./\".\neffi:handle_request( EffiRequest, Dir ).\n```\n\nEffi starts evaluating the request, expecting input data in and writing output data to the working directory given in the variable `Dir`.\n\nThe `handle_request/2` function returns a reply-map summarizing the result of the computation.\n\n## Effi JSON Exchange Format\n\nEffi is driven by task instantiations or applications. Running effi on an application results in a reply. Here, we describe the application format and the reply format.\n\n### Example\n\nBelow is an example for an Effi request (an application):\n\n```json\n{ \"app_id\": \"1234\",\n  \"lambda\": { \"lambda_name\":  \"bowtie2-build\",\n              \"arg_type_lst\": [{ \"arg_name\": \"fa\",\n                                 \"arg_type\": \"File\",\n                                 \"is_list\":  false }],\n              \"ret_type_lst\": [{ \"arg_name\": \"idx\",\n                                 \"arg_type\": \"File\",\n                                 \"is_list\":  false }],\n              \"lang\":         \"Bash\",\n              \"script\":       \"bowtie2-build $fa bt2idx\\nidx=idx.tar\\ntar cf $idx --remove-files bt2idx.*\\n\" },\n  \"arg_bind_lst\": [{ \"arg_name\": \"fa\",\n                     \"value\":    \"chr22.fa\" }] }\n```\n\nThe following is an example for an Effi reply:\n\n```json\n{ \"app_id\": \"1234\",\n  \"result\": { \"status\":       \"ok\",\n              \"node\":         \"cf_worker@x240\",\n              \"stat\":         { \"run\": { \"t_start\":  \"1523007609917834743\",\n                                         \"duration\": \"30391761645\" } },\n              \"ret_bind_lst\": [{ \"arg_name\": \"idx\",\n                                 \"value\":    \"idx.tar\" }] } }\n```\n\nThe start time `tstart` is given in nanoseconds from 1970-01-01 and also the the wall-clock running time `duration` is given in nanoseconds. So the example ran `bowtie2-build` for about 30.4 seconds. The `node` field identifies the Erlang node name of the worker instance that ran the task.\n\n### Request Format\n\nThe Effi request (application) format is what is consumed. An application `App` has the following form:\n\n    App ::= { \"app_id\":       S,\n              \"lambda\":       Lambda, \n              \"arg_bind_lst\": [Bind, ...] }\n\nThe application's lambda expression `Lambda` has the following form:\n\n    Lambda ::= { \"lambda_name\":  S,\n                 \"arg_type_lst\": [TArg, ...],\n                 \"ret_type_lst\": [TArg, ...],\n                 \"lang\":         Lang,\n                 \"script\":       S }\n\nA lambda expression's `arg_type_lst` pair lists specifications for the input parameters while the `ret_type_lst` pair lists specifications for the output parameters of a lambda. An input or output parameter specification `TArg` has the following form:\n\n    TArg ::= { \"arg_name\": S,\n               \"arg_type\": Type,\n               \"is_list\":  B }\n\nThe `arg_type` pair provides the base type of the argument. The base type `Type` has the following form:\n\n    Type ::= \"Bool\"\n           | \"Str\"\n           | \"File\"\n\n\nThe `lang` pair provides the programming language in which the script is written. The language `Lang` has the following form:\n\n    Lang ::= \"Bash\"\n           | \"Erlang\"\n           | \"Java\"\n           | \"Matlab\"\n           | \"Octave\"\n           | \"Perl\"\n           | \"Python\"\n           | \"R\"\n           | \"Racket\"\n\nA lambda expression contains a list of argument bindings `Bind` of the following form:\n\n    Bind ::= { \"arg_name\": S, \"value\": S}\n           | { \"arg_name\": S, \"value\": [S, ...] }\n\n    B ::= true\n        | false\n\n    S ::= \"...\"\n\n### Reply Format\n\nThe Effi reply format is what is produced.\n\n    Reply ::= { \"app_id\": S,\n                \"result\": Result }\n\n    Result ::= { \"status\": \"ok\",\n                 \"node\":   S,\n                 \"stat\":   { \"run\":  { \"t_start\": S, \"duration\": S } },\n                 \"ret_bind_lst\": [Bind, ...] }\n             | { \"status\":          \"error\",\n                 \"node\":            S\n                 \"stage\":           \"run\",\n                 \"extended_script\": S,\n                 \"output\":          S }\n             | { \"status\":   \"error\",\n                 \"node\":     S\n                 \"stage\":    \"stagein\",\n                 \"file_lst\": [S, ...] }\n             | { \"status\":   \"error\",\n                 \"node\":     S\n                 \"stage\":    \"stageout\",\n                 \"file_lst\": [S, ...] }\n\n\n\n\n\n\n## System Requirements\n\n- [Erlang](https://www.erlang.org) OTP 18.0 or higher\n- [Rebar3](https://www.rebar3.org) 3.0.0 or higher\n\n## Resources\n\n- [joergen7/cf_worker](https://github.com/joergen7/cf_worker). A Cuneiform worker implementation.\n- [joergen7/cuneiform](https://github.com/joergen7/cuneiform). A functional language for large-scale data analysis.\n\n\n## Authors\n\n- Jörgen Brandt ([@joergen7](https://github.com/joergen7/)) [joergen.brandt@onlinehome.de](mailto:joergen.brandt@onlinehome.de)\n- Carl Witt ([@carlwitt](https://github.com/carlwitt))\n- [@bharendt](https://github.com/bharendt)\n\n## License\n\n[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Feffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoergen7%2Feffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Feffi/lists"}