Skip to content

Refactoring router to utilize get_session_context#411

Merged
gialmisi merged 12 commits intoindustrial-optimization-group:masterfrom
PtrBednarik:master
Jan 28, 2026
Merged

Refactoring router to utilize get_session_context#411
gialmisi merged 12 commits intoindustrial-optimization-group:masterfrom
PtrBednarik:master

Conversation

@PtrBednarik
Copy link
Copy Markdown
Contributor

@PtrBednarik PtrBednarik requested a review from gialmisi January 23, 2026 14:23
Comment thread desdeo/api/routers/nimbus.py Outdated
Comment thread desdeo/api/routers/nimbus.py Outdated
Comment thread desdeo/api/routers/problem.py Outdated
Comment thread desdeo/api/routers/reference_point_method.py Outdated
Comment thread desdeo/api/routers/utils.py
Comment thread desdeo/api/routers/utils.py Outdated
Comment thread desdeo/api/routers/utils.py
Comment thread desdeo/api/routers/utils.py Outdated
parent_state=parent_state,
)

def get_session_context_base(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really needed since calling SessionContext(user=..., db_session=...) is already equivalent to this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now, I think it is. Tests failed when I tried to use get_session_context() method at endpoint which do not contain request data. So I created a method, which does not require request parameter.
When I asked Chatbot for help, got answer like this -
"Because FastAPI dependencies must be callable, and you cannot use a union type RequestType as a dependency.
The only way to reuse the same context structure in endpoints without request data is to provide a dedicated dependency function."

But if is it wrong way of thinking, let me know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, this makes sense then. I renamed the function to be more descriptive.

Comment thread desdeo/api/models/nimbus.py
- Linter related changes, like removing deprecated imports and sorting
  them.
- Other syntax changes.
Copy link
Copy Markdown
Contributor

@gialmisi gialmisi left a comment

Choose a reason for hiding this comment

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

Good, thank you!

See PtrBednarik#4 (some changes I made while reviewing that should be incorporated). Please merge these into your branch when updating the PR. Check my comments for more details what needs to change. I might not have added a comment everywhere were a repeated issues has risen (e.g., with the missing docstrings), so please generalize when needed.

Some notes:

@gialmisi gialmisi merged commit 540991d into industrial-optimization-group:master Jan 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants