Unique constraint and Link Type ID error

18 views
Skip to first unread message

Connor Williams

unread,
Jan 29, 2025, 7:16:18 PMJan 29
to AequilibraE
Hey again, 

Another error I'm running into when I run create_from_gmns is a unique constraint error. When I try to add my link types to a project, I get the following:

Traceback (most recent call last):
  File "//app/userdata/Worked_on_Code/Create_from_gmns.py", line 133, in <module>
    project.network.create_from_gmns(link_file, node_file, use_group)
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/network.py", line 253, in create_from_gmns
    gmns_builder.doWork()
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/gmns_builder.py", line 174, in doWork
    link_types_list = self.save_types_to_aeq()
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/gmns_builder.py", line 348, in save_types_to_aeq
    new_type.save()
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/link_type.py", line 23, in save
    conn.execute("Insert into link_types (link_type_id, link_type) values(?,?)", data)
sqlite3.IntegrityError: UNIQUE constraint failed: link_types.link_type



I believe it's not recognizing that the centroid _connector in the file is the same as one of the two defaults in AequilibraE. So it reads it into the project and the unique constraint fails. 

When I remove the centroid_contector link_type, I get the error below.


Traceback (most recent call last):
  File "//app/userdata/Worked_on_Code/Create_from_gmns.py", line 133, in <module>
    project.network.create_from_gmns(link_file, node_file, use_group)
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/network.py", line 253, in create_from_gmns
    gmns_builder.doWork()
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/gmns_builder.py", line 174, in doWork
    link_types_list = self.save_types_to_aeq()
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/gmns_builder.py", line 345, in save_types_to_aeq
    new_type = link_types.new(letters[0])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aequilibrae/project/network/link_types.py", line 80, in new
    raise ValueError(f"Link Type ID ({link_type_id}) already exists in the model. It must be unique.")
ValueError: Link Type ID (m) already exists in the model. It must be unique.


I'm quite confused why either of these errors are happening. I followed the examples on how to add link types and assign them Unique ids, but it's not working. Any help will be greatly appreciated. 

Thanks.
Create_from_gmns.py
link file screenshot.png

Pedro Camargo

unread,
Jan 29, 2025, 8:15:59 PMJan 29
to AequilibraE
Hi Connor,

Have you tried debugging the code to understand what is the exact scenario where the error occurs?

Cheers,
Pedro



---- On Thu, 30 Jan 2025 10:16:18 +1000 Connor Williams <xcronl...@gmail.com> wrote ---

--
You received this message because you are subscribed to the Google Groups "AequilibraE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aequilibrae...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/aequilibrae/9f77f0ed-77b9-4793-a1c3-a03074506c25n%40googlegroups.com.


Pedro Camargo

unread,
Jan 31, 2025, 6:40:05 PMJan 31
to AequilibraE
Hi Connor,

The other thing think about here as well is that working inside a Docker container adds another level of annoyance (if not complication) when debugging code.  Is there any particular reason why you are using Docker instead of developing it natively?

Cheers,
Pedro



---- On Thu, 30 Jan 2025 11:15:51 +1000 Pedro Camargo <c...@margo.co> wrote ---

Hi Connor,

Have you tried debugging the code to understand what is the exact scenario where the error occurs?

Cheers,
Pedro



---- On Thu, 30 Jan 2025 10:16:18 +1000 Connor Williams <xcronl...@gmail.com> wrote ---





--
You received this message because you are subscribed to the Google Groups "AequilibraE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aequilibrae...@googlegroups.com.

Connor Williams

unread,
Feb 4, 2025, 5:25:09 PMFeb 4
to AequilibraE
We're using docker because we were unable to get Aequilibrae to work on Mac or window based OS. SpatiaLite wasn't working for windows, and I can't remember off the top of my head why Mac didn't work. But you're right about the added layer of complication. I haven't been able to get a debugger to work inside the docker container. 

Pedro Camargo

unread,
Feb 4, 2025, 6:10:01 PMFeb 4
to AequilibraE
Hey Connor,

The newest release should work perfectly on any Windows PC, so I would recommend trying it again.  As for Mac releases, there is always the alternative of compiling it locally, which should not be too challenging.

Cheers,
Pedro



---- On Wed, 05 Feb 2025 08:25:09 +1000 Connor Williams <xcronl...@gmail.com> wrote ---

zx1577...@hotmail.com

unread,
Feb 6, 2025, 9:05:33 PMFeb 6
to xcronlawlimas, aequilibrae
thanks a lot


---- Replied Message ----
From Connor Williams<xcronl...@gmail.com>
Date 02/05/2025 06:25
To AequilibraE<aequi...@googlegroups.com>
Cc
Subject Re: Unique constraint and Link Type ID error

Connor Williams

unread,
Feb 10, 2025, 3:24:16 PMFeb 10
to AequilibraE
After running a debugger, I've found that the unique constrain is caused by 'create_from_gmns'  reading in my 'centroid_connectors' as a new link type instead of recognizing them as one of the two default link types. This is causing two 'centroid_connectors' to be in the project, causing the unique constraint error to happen. 

So my question is, how do I get Aequilibrae to not read the centroids as a new type but one that already exists? 

Pedro Camargo

unread,
Feb 11, 2025, 1:42:33 AMFeb 11
to Aequilibrae
The simple answer is that you don't in its current version. 

As a workaround, you can change that link type in GMNS, import the network, change the link types to centroid_connector and delete the new type that was created.

Pedro



============ Forwarded message ============
From: Connor Williams <xcronl...@gmail.com>
To: "AequilibraE"<aequi...@googlegroups.com>
Date: Tue, 11 Feb 2025 06:24:16 +1000

Subject: Re: Unique constraint and Link Type ID error
============ Forwarded message ============

Reply all
Reply to author
Forward
0 new messages