Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Add type annotations to db/sqla/__init__ #6733

Merged
merged 1 commit into from May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/rucio/db/sqla/__init__.py
Expand Up @@ -12,10 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING, Optional, TypeVar

from sqlalchemy.sql.expression import bindparam, text

if TYPE_CHECKING:
from sqlalchemy.orm import Session
from sqlalchemy.orm.query import RowReturningQuery
from sqlalchemy.sql.selectable import Select

Q = TypeVar('Q', RowReturningQuery, Select)


def filter_thread_work(session, query, total_threads, thread_id, hash_variable=None):
def filter_thread_work(
session: "Session",
query: "Q",
total_threads: Optional[int],
thread_id: Optional[int],
hash_variable: Optional[str] = None
) -> "Q":
""" Filters a query to partition thread workloads based on the thread id and total number of threads """
if thread_id is not None and total_threads is not None and (total_threads - 1) > 0:
if session.bind.dialect.name == 'oracle':
Expand Down