Skip to content

Commit 25ac8d0

Browse files
committed
More contexts
1 parent 47f03b9 commit 25ac8d0

File tree

2 files changed

+33
-49
lines changed

2 files changed

+33
-49
lines changed

src/murfey/client/contexts/atlas.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from murfey.client.contexts.spa import _get_source
77
from murfey.client.contexts.spa_metadata import _atlas_destination
88
from murfey.client.instance_environment import MurfeyInstanceEnvironment
9-
from murfey.util.api import url_path_for
109
from murfey.util.client import capture_post
1110

1211
logger = logging.getLogger("murfey.client.contexts.atlas")
@@ -40,8 +39,11 @@ def post_transfer(
4039
environment, source, transferred_file
4140
) / transferred_file.relative_to(source.parent)
4241
capture_post(
43-
f"{str(environment.url.geturl())}{url_path_for('session_control.spa_router', 'make_atlas_jpg', session_id=environment.murfey_session)}",
44-
json={"path": str(transferred_atlas_name)},
42+
base_url=str(environment.url.geturl()),
43+
router_name="session_control.spa_router",
44+
function_name="make_atlas_jpg",
45+
session_id=environment.murfey_session,
46+
data={"path": str(transferred_atlas_name)},
4547
)
4648
logger.info(
4749
f"Submitted request to create JPG image of atlas {str(transferred_atlas_name)!r}"

src/murfey/client/contexts/clem.py

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from murfey.client.context import Context
1515
from murfey.client.instance_environment import MurfeyInstanceEnvironment
16-
from murfey.util.api import url_path_for
1716
from murfey.util.client import capture_post, get_machine_config_client
1817

1918
# Create logger object
@@ -353,19 +352,14 @@ def register_lif_file(
353352
register the LIF file in the database correctly as part of the CLEM workflow.
354353
"""
355354
try:
356-
# Construct URL to post to post the request to
357-
url = f"{environment.url.geturl()}{url_path_for('clem.router', 'register_lif_file', session_id=environment.murfey_session)}?lif_file={quote(str(lif_file), safe='')}"
358-
# Validate
359-
if not url:
360-
logger.error(
361-
"URL could not be constructed from the environment and file path"
362-
)
363-
return False
364-
365-
# Send the message
366-
capture_post(url)
355+
capture_post(
356+
base_url=str(environment.url.geturl()),
357+
router_name="clem.router",
358+
function_name="register_lif_file",
359+
session_id=environment.murfey_session,
360+
data={"lif_file": quote(str(lif_file), safe="")},
361+
)
367362
return True
368-
369363
except Exception as e:
370364
logger.error(
371365
f"Error encountered when registering the LIF file in the database: {e}"
@@ -383,19 +377,14 @@ def process_lif_file(
383377
"""
384378

385379
try:
386-
# Construct the URL to post the request to
387-
url = f"{environment.url.geturl()}{url_path_for('clem.router', 'process_raw_lifs', session_id=environment.murfey_session)}?lif_file={quote(str(lif_file), safe='')}"
388-
# Validate
389-
if not url:
390-
logger.error(
391-
"URL could not be constructed from the environment and file path"
392-
)
393-
return False
394-
395-
# Send the message
396-
capture_post(url)
380+
capture_post(
381+
base_url=str(environment.url.geturl()),
382+
router_name="clem.router",
383+
function_name="process_raw_lifs",
384+
session_id=environment.murfey_session,
385+
data={"lif_file": quote(str(lif_file), safe="")},
386+
)
397387
return True
398-
399388
except Exception as e:
400389
logger.error(f"Error encountered processing LIF file: {e}")
401390
return False
@@ -411,17 +400,14 @@ def register_tiff_file(
411400
"""
412401

413402
try:
414-
url = f"{environment.url.geturl()}{url_path_for('clem.router', 'register_tiff_file', session_id=environment.murfey_session)}?tiff_file={quote(str(tiff_file), safe='')}"
415-
if not url:
416-
logger.error(
417-
"URL could not be constructed from the environment and file path"
418-
)
419-
return False
420-
421-
# Send the message
422-
capture_post(url)
403+
capture_post(
404+
base_url=str(environment.url.geturl()),
405+
router_name="clem.router",
406+
function_name="register_tiff_file",
407+
session_id=environment.murfey_session,
408+
data={"tiff_file": quote(str(tiff_file), safe="")},
409+
)
423410
return True
424-
425411
except Exception as e:
426412
logger.error(
427413
f"Error encountered when registering the TIFF file in the database: {e}"
@@ -439,18 +425,14 @@ def process_tiff_series(
439425
"""
440426

441427
try:
442-
# Construct URL for Murfey server to communicate with
443-
url = f"{environment.url.geturl()}{url_path_for('clem.router', 'process_raw_tiffs', session_id=environment.murfey_session)}"
444-
if not url:
445-
logger.error(
446-
"URL could not be constructed from the environment and file path"
447-
)
448-
return False
449-
450-
# Send the message
451-
capture_post(url, json=tiff_dataset)
428+
capture_post(
429+
base_url=str(environment.url.geturl()),
430+
router_name="clem.router",
431+
function_name="process_raw_tiffs",
432+
session_id=environment.murfey_session,
433+
data=tiff_dataset,
434+
)
452435
return True
453-
454436
except Exception as e:
455437
logger.error(f"Error encountered processing the TIFF series: {e}")
456438
return False

0 commit comments

Comments
 (0)