dmgolembiowski / edgemorph

EdgeDB manipulator of relational, polymorphic hierarchies
Other
16 stars 1 forks source link

TypeError: compile() takes 1 positional argument but 2 were given #5

Closed dmgolembiowski closed 3 years ago

dmgolembiowski commented 4 years ago

Summary

Running edm make | edm make * fails when multiple module files are reachable within edgemorph.toml.

Recreation Steps

  1. edm init etest
  2. Update edgemorph.toml manually:
    
    [edgemorph]
    project_root    = "etest"
    mod_directories = ["/edb_modules"]

[edgemorph.codegen] schema_name = "Test"

[edgemorph.codegen.rust] enabled = "true"

[edgemorph.codegen.rust.modules] [edgemorph.codegen.rust.modules.etest] source = "/edb_modules/etest.esdl" output = "/src/lib/edm_etest.rs" [edgemorph.codegen.rust.modules.cinema] source = "/edb_modules/cinema.esdl" output = "/src/lib/edm_cinema.rs"

[edgemorph.codegen.python] enabled = "true"

[edgemorph.codegen.python.modules] [edgemorph.codegen.python.modules.etest] source = "/edb_modules/etest.esdl" output = "/etest/edm_etest.py" [edgemorph.codegen.python.modules.cinema] source = "/edb_modules/cinema.esdl" output = "/etest/edm_cinema.py"

[edgedb] [edgedb.databases] [edgedb.databases.primary] name = "" dsn = ""

[edgedb.databases.primary.modules] etest = "/edb_modules/etest.esdl" cinema = "/edb_modules/cinema.esdl"

2. `cd etest/edb_modules`
3. Edit `etest.esdl`:
```sql
module etest {
    type User {
        property email -> str;
        property password -> str;
        property name -> str;
    };
    type Session {
        required single link user -> User;
        required single property allottedDuration -> std::duration {
            default := (WITH
                MODULE api
            SELECT
                <duration>'24 hours'
            );
        };
        required single property createdAt -> std::datetime {
            default := (WITH
                MODULE api
            SELECT
                datetime_current()
            );
        };
        required single property sessionID -> std::str;
        single property token -> std::str;
    };
    function create_new_session(EMAIL: std::str, PASS: std::str) -> SET OF Session using (
        FOR USER IN {validate_credentials(EMAIL, PASS)}
            UNION (
                INSERT Session {
                    token := <str>(SELECT random_big_str_id()),
                    sessionID := <str>(SELECT random_big_str_id()),
                    user := USER
                }   
            )
         );

    function validate_credentials(EMAIL: std::str, PASS: std::str) -> SET OF User using (
            SELECT
                User
            FILTER
                .email = EMAIL
                AND
                .password = PASS
            LIMIT 1
        );
}

then write and quit.

  1. In the same directory, open and write cinema.esdl :
    module cinema {
    type Movie {
        required property title -> str;
        # the year of release
        property year -> int64;
        required link director -> Person;
        required multi link actors -> Person;
    }
    type Person {
        required property first_name -> str;
        required property last_name -> str;
    }
    }

    Output:

    
    (bootstrap) 1018 $ edm make
    ../edgemorph.toml
    Compiling your EdgeDB modules....
    multiprocessing.pool.RemoteTraceback: 
    """
    Traceback (most recent call last):
    File "/home/david/.pyenv/versions/3.8-dev/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
    TypeError: compile() takes 1 positional argument but 2 were given
    """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/david/code/edgemorph/edm/edm", line 715, in main(args) File "/home/david/code/edgemorph/edm/edm", line 599, in main eval(f"{func_name}(arg)") File "", line 1, in File "/home/david/code/edgemorph/edm/edm", line 293, in make batch_compilation(retrieved) File "/home/david/code/edgemorph/edm/edm", line 309, in batch_compilation async_res = [ File "/home/david/code/edgemorph/edm/edm", line 310, in job.get(timeout=12) File "/home/david/.pyenv/versions/3.8-dev/lib/python3.8/multiprocessing/pool.py", line 771, in get raise self._value TypeError: compile() takes 1 positional argument but 2 were given