'python regex matching only if the groups are between a special character

I'm working with a dataframe with some medicines and I want extract the dosages from a full sentence taken from the product description.

Example of what I want:

Dexamethasonacetat 5 mg/10 mg, Lidocain-HCl 1H2O 30 mg/60 mg
#['5mg/10mg','30mg/60mg']

Anakinra 120 mg /-20 g /-12mg gentechnologisch hergestellt aus E. coli. 10mg pack
#['120mg/20g/12mg']

I can extract the dosage using \d+(?:[.,]\d+)*\s*(g|mg|), which gets me:

Dexamethasonacetat 5 mg/10 mg, Lidocain-HCl 1H2O 30 mg/60 mg
#['5mg','10mg','30mg','60mg']

Anakinra 120 mg /-20 g /-12mg gentechnologisch hergestellt aus E. coli. 10mg pack
#['120mg','20g','12mg','10mg]

It would be easier to do this if / only happens once, but it can happen multiple times..



Solution 1:[1]

I am also experiencing this issue. It started after I upgraded from Airflow 2.2.2 to 2.3.0. This custom class derives from HttpSensor.

check_stuff = AuthorizedHttpSensor(
    task_id="check_stuff_sensor",
    poke_interval=60 * 10,
    timeout=60 * 60 * 7,
    mode="reschedule",
    retries=50,
    soft_fail=False,
    authorize_conn_id = authorize_conn_id,
    endpoint= "stuff",
    http_conn_id = "stuff_conn_id",
)

Results in the following error:

[2022-06-14, 02:20:35] {taskinstance.py:1853} INFO - Rescheduling task, marking task as UP_FOR_RESCHEDULE
[2022-06-14, 02:20:35] {local_task_job.py:156} INFO - Task exited with return code 0

I have the same issue for all kind of sensors after updating to Airflow 2.3.0. Our temporary solution is to change "reschedule" to "poke" but as you know, it occupies a pool for a long time if the sensor does not succeed. I will post a real fix as soon as I find something other than the temporary fix :)

EDIT: Updating to Airflow 2.3.2 worked for me!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1