Skip to content

osm_to_railjson: Create fake UIC and name for op#15744

Open
SaumonDesMers wants to merge 2 commits intodevfrom
sga/generate_op
Open

osm_to_railjson: Create fake UIC and name for op#15744
SaumonDesMers wants to merge 2 commits intodevfrom
sga/generate_op

Conversation

@SaumonDesMers
Copy link
Contributor

Generate a fake UIC code for operational points that don't have one.
We use the UIC code 11 which is not used anywhere.
And we generate a fake name from the UIC code.

close #15692

@SaumonDesMers SaumonDesMers self-assigned this Mar 13, 2026
@SaumonDesMers SaumonDesMers requested a review from a team as a code owner March 13, 2026 15:46
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Mar 13, 2026
Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to fix OSRD to not require UIC, instead of faking one.

Comment on lines +550 to +554
static mut UIC_COUNTER: u32 = 0;
unsafe {
UIC_COUNTER += 1;
11_00000 + UIC_COUNTER
}
Copy link
Contributor

@Khoyo Khoyo Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. You cannot use unsafe like this (in a multithreaded context, this would be a data race. It's uncertain we would notice if the context becomes multithreaded).

static UIC_COUNTER: AtomicU32 = AtomicU32::new(0);
11_00000 + UIC_COUNTER.fetch_add(1, Ordering::Relaxed);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 3b88ad2.

Copy link
Member

@flomonster flomonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to generate an UIC code when not found?

@SaumonDesMers
Copy link
Contributor Author

Currently, the Identifier extension is mandatory in the front (i.e. it crashes when it's not present). And to my understanding, there is no way to identify an op, other than the Identifier. So without a serious rework of the front and/or the data model (which I believe will come), generating a fake Identifier is the only easy way to fix this.

When generating an Identifier, we have to generate a name and an UIC code (they are not optional). We could maybe use an empty string and an UIC code of 0, but I'm sure how other part of the code base will react to non-unique Identifier.

All of this is a temporary fix, and I will add comments in this sens.

@emersion
Copy link
Member

emersion commented Mar 16, 2026

I didn't recall that the name and the uic were both baked together in the identifier extension, and that one cannot specify one without the other. That's quite cumbersome, and will be fixed with https://github.com/osrd-project/osrd-confidential/issues/1027.

In the meantime, I don't see a better way to go forward. Please add a TODO explaining that the fake UIC should be dropped.

Generate a fake UIC code for operational points that don't have one.
We use the UIC code 11 which is not used anywhere.
And we generate a fake name from the UIC code.

Signed-off-by: Simon <sim.gaubert.sg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editoast Work on Editoast Service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

osm-to-railjson: generate operational points identifier when missing

4 participants