Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
17aca93
Add process column to Session table to record if processing is reques…
d-j-hatton May 9, 2025
dc652ba
Allow analysis to be turned off via a query parameter
d-j-hatton May 9, 2025
8f38607
The server can work out from the session whether there should be proc…
d-j-hatton May 12, 2025
8ee1de8
Add some prefixes and tags to existing routers
d-j-hatton May 12, 2025
97b16c8
More moving endpoints around
d-j-hatton May 12, 2025
76b43b6
Move workflow setup specific endpoints to their own router
d-j-hatton May 12, 2025
a9c50db
Still moving endpoints under their own routers
d-j-hatton May 12, 2025
4c2971e
Move SPA and tomo workflow endpoints
d-j-hatton May 13, 2025
0538013
More endpoint moving
d-j-hatton May 13, 2025
90db284
Move most context API calls to use a lookup based on function name ra…
d-j-hatton May 14, 2025
ed99d47
Make two endpoints in the cases where functionality needs to be share…
d-j-hatton May 14, 2025
c3e03d8
More moving shared endpoints
d-j-hatton May 14, 2025
23119cb
Move grid square and foil hole endpoints
d-j-hatton May 14, 2025
e4d2dd7
Move correlative workflow related endpoints
d-j-hatton May 14, 2025
0b9c459
Move some remaining generic endpoints
d-j-hatton May 14, 2025
ffb6d8d
Move prometheus update endpoints
d-j-hatton May 14, 2025
533d47b
Translate some URLs from TUI app
d-j-hatton May 14, 2025
14bc081
Clear URLs from app.py
d-j-hatton May 15, 2025
6443c34
The last big push to switch to using routers to determine URLs
d-j-hatton May 20, 2025
986905a
Function changed position in code
d-j-hatton May 21, 2025
9a427a2
Fix typo
d-j-hatton May 21, 2025
3f6d415
Some test fixing
d-j-hatton May 21, 2025
9975d95
URL fix
d-j-hatton May 21, 2025
c1f06ab
Mocking the wrong thing now
d-j-hatton May 21, 2025
477f58c
visit now needed in environment as it is used by url_path_for functio…
d-j-hatton May 21, 2025
726c5b1
Merge main
d-j-hatton May 21, 2025
8f3bfe1
Small fix
d-j-hatton May 21, 2025
9ba6410
Moved 'sanitise()' and 'sanitise_path()' from 'murfey.server.__init__…
tieneupin May 21, 2025
87db4a3
Emptied out 'murfey.server.__init__' as part of eliminating unnecessa…
tieneupin May 21, 2025
dfacae2
'murfey.server' entry point needed to be updated
tieneupin May 21, 2025
807c8cf
Emptied out 'murfey.server.api.__init__'; migrated 'inspect_prometheu…
tieneupin May 21, 2025
8e3bd26
Fixed broken imports due to 'murfey.server' refactor; moved FastAPI t…
tieneupin May 22, 2025
ef9e7e3
Removed 'tests/client/test.py' as it's very outdated
tieneupin May 22, 2025
4e7bca2
Moved 'murfey.server.websocket' to 'murfey.server.api.websocket'; fix…
tieneupin May 22, 2025
22603a1
Fixed broken import in 'spa_ispyb_messages' CLI due to 'murfey.server…
tieneupin May 22, 2025
da5a7ab
Adjusted imports of 'murfey.server.ispyb.DB'; imported the object as …
tieneupin May 22, 2025
340fe8f
Reverted unexpected change to how analysers are disabled in 'start_mu…
tieneupin May 22, 2025
eaa16af
Titlecased router names; rearranged order of routers as loaded in the…
tieneupin May 22, 2025
b758b60
Created route manifest of all the routers, paths, and endpoint functi…
tieneupin May 22, 2025
ad5d0a2
Added path parameter information to route manifest
tieneupin May 22, 2025
6629a12
Added utility function and supporting functions to generate URL path …
tieneupin May 22, 2025
55e71d8
Updated function documentation
tieneupin May 23, 2025
589fce7
Replaced 'router.url_path_for()' instances in client with use of our …
tieneupin May 23, 2025
3caeb0c
Re-added 'register_client_to_visit()' to 'murfey.server.api.session_c…
tieneupin May 23, 2025
cb499fb
Added 'register_client_to_visit' to route manifest
tieneupin May 23, 2025
12a6000
Added logging to 'murfey.util.api'
tieneupin May 23, 2025
12b4116
Replaced most other instances of URL requests to the instrument or ba…
tieneupin May 23, 2025
9e17e5a
Added CLI to generate FastAPI route manifest
tieneupin May 23, 2025
c37d5d9
Added logic to toggle partial or exact matches between str pattern an…
tieneupin May 23, 2025
863a61c
Fixed broken API call in tests
tieneupin May 23, 2025
015c7e8
Typo in function name
tieneupin May 23, 2025
0b4fc6b
Changed incoming path parameters validation logic
tieneupin May 23, 2025
214baeb
Updated Docker images used to newer versions
tieneupin May 23, 2025
bdf7256
Added route manifest as a file to add to Python package upon install
tieneupin May 23, 2025
24b4461
Convert UUID4 into string upon generation
tieneupin May 23, 2025
86316a9
Some types are complicated 'typing' strings; skip validating those fo…
tieneupin May 23, 2025
219f14e
Used wrong function name
tieneupin May 23, 2025
4e2e6c9
More detail in error logs
tieneupin May 23, 2025
c628091
Fixed typo in when calling 'suggest_path'
tieneupin May 23, 2025
841dac7
Use 'murfey.server._transport_object' directly as in 'murfey.server.f…
tieneupin May 27, 2025
3eaa517
Logs to keep track of 'TransportManager' setup upon server startup
tieneupin May 27, 2025
49a39f0
Standardised how the Analyser, DirWatcher, and Rsyncer objects are re…
tieneupin May 27, 2025
43dca41
Forgot to close the bracket
tieneupin May 27, 2025
a917ba1
Fixed broken imports in SPA workflows module
tieneupin May 27, 2025
5d122b6
Convert grid square name ('gs_name') into int upon extraction instead
tieneupin May 27, 2025
067e70f
Searched for 'start_dc' under wrong router
tieneupin May 27, 2025
9ecc94c
Looked for 'register_spa_proc_params' under wrong router
tieneupin May 27, 2025
69afc1d
Merged CLEM workflow fix changes into current branch
tieneupin May 27, 2025
7d34ed5
Updated logs and parameter names in 'murfey.util.api'
tieneupin May 28, 2025
ba85127
Made sure that 'gsid' in 'register_grid_square' receives an int
tieneupin May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfiles/murfey-instrument-server
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# podman build --build-arg groupid=<groupid> --build-arg userid=<userid> --build-arg groupname=<groupname> --no-cache -f path/to/Dockerfiles/murfey-instrument-server -t murfey-instrument-server:<version> path/to/python-murfey

# Set up the base image to build with
FROM docker.io/library/python:3.12.8-slim-bullseye AS base
FROM docker.io/library/python:3.12.10-slim-bookworm AS base

# Install Vim in base image
RUN apt-get update && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/murfey-rsync
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Template build command
# podman build --build-arg groupid=<groupid> --build-arg userid=<userid> --build-arg groupname=<groupname> --no-cache -f path/to/Dockerfiles/murfey-rsync

FROM docker.io/library/alpine:3.20
FROM docker.io/library/alpine:3.21
# FROM alpine:3.14

ARG groupid
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/murfey-server
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# podman build --build-arg groupid=<groupid> --build-arg userid=<userid> --build-arg groupname=<groupname> --no-cache -f path/to/Dockerfiles/murfey-server -t murfey-server:<version> path/to/python-murfey

# Set up the base image to build with
FROM docker.io/library/python:3.12.8-slim-bullseye AS base
FROM docker.io/library/python:3.12.10-slim-bookworm AS base

# Install Vim and PostgreSQL dependencies in base image
RUN apt-get update && \
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ GitHub = "https://github.com/DiamondLightSource/python-murfey"
"murfey.decrypt_password" = "murfey.cli.decrypt_db_password:run"
"murfey.generate_key" = "murfey.cli.generate_crypto_key:run"
"murfey.generate_password" = "murfey.cli.generate_db_password:run"
"murfey.generate_route_manifest" = "murfey.cli.generate_route_manifest:run"
"murfey.instrument_server" = "murfey.instrument_server:run"
"murfey.repost_failed_calls" = "murfey.cli.repost_failed_calls:run"
"murfey.server" = "murfey.server:run"
"murfey.server" = "murfey.server.run:run"
"murfey.sessions" = "murfey.cli.db_sessions:run"
"murfey.simulate" = "murfey.cli.dummy:run"
"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run"
Expand Down Expand Up @@ -117,6 +118,7 @@ zip-safe = false

[tool.setuptools.package-data]
"murfey.client.tui" = ["*.css"]
"murfey.util" = ["route_manifest.yaml"]

[tool.setuptools.packages.find]
where = ["src", "tests"]
Expand Down
20 changes: 14 additions & 6 deletions src/murfey/bootstrap/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import pathlib
import subprocess
import sys
from urllib.parse import urlparse
from urllib.parse import ParseResult, urlparse
from urllib.request import urlopen

from murfey.util.api import url_path_for

"""
A script to simplify installing Murfey on a network-isolated machine.
This could in theory be invoked by
Expand Down Expand Up @@ -64,10 +66,13 @@
# Construct a minimal base path string
# Extract the host name for pip installation purposes
try:
murfey_url = urlparse(args.server)
murfey_url: ParseResult = urlparse(args.server)

Check warning on line 69 in src/murfey/bootstrap/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/bootstrap/__main__.py#L69

Added line #L69 was not covered by tests
except Exception:
exit(f"{args.server} is not a valid URL")
murfey_proxy_path = murfey_url.path.rstrip("/")

Check warning on line 72 in src/murfey/bootstrap/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/bootstrap/__main__.py#L72

Added line #L72 was not covered by tests
murfey_base = f"{murfey_url.scheme}://{murfey_url.netloc}"
if murfey_proxy_path:
murfey_base = f"{murfey_base}{murfey_proxy_path}"

Check warning on line 75 in src/murfey/bootstrap/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/bootstrap/__main__.py#L75

Added line #L75 was not covered by tests
murfey_hostname = murfey_url.netloc.split(":")[0]

# Check that Python version is supported
Expand All @@ -82,7 +87,10 @@
# Step 1: Download pip wheel
print()
print(f"1/4 -- Connecting to murfey server on {murfey_base}...")
_download_to_file(f"{murfey_base}/bootstrap/pip.whl", "pip.whl")
_download_to_file(

Check warning on line 90 in src/murfey/bootstrap/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/bootstrap/__main__.py#L90

Added line #L90 was not covered by tests
f"{murfey_base}{url_path_for('bootstrap.bootstrap', 'get_pip_wheel')}",
"pip.whl",
)

# Step 2: Get pip to install itself
print()
Expand All @@ -96,7 +104,7 @@
"--trusted-host",
murfey_hostname,
"-i",
f"{murfey_base}/pypi",
f"{murfey_base}{url_path_for('bootstrap.pypi', 'get_pypi_index')}",
"pip",
]
)
Expand All @@ -116,7 +124,7 @@
"--trusted-host",
murfey_hostname,
"-i",
f"{murfey_base}/pypi",
f"{murfey_base}{url_path_for('bootstrap.pypi', 'get_pypi_index')}",
"--upgrade",
"pip",
]
Expand All @@ -135,7 +143,7 @@
"--trusted-host",
murfey_hostname,
"-i",
f"{murfey_base}/pypi",
f"{murfey_base}{url_path_for('bootstrap.pypi', 'get_pypi_index')}",
"murfey[client]",
]
)
Expand Down
138 changes: 138 additions & 0 deletions src/murfey/cli/generate_route_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
"""
CLI to generate a manifest of the FastAPI router paths present in both the instrument
server and backend server to enable lookup of the URLs based on function name.
"""

import importlib
import inspect
import pkgutil
from argparse import ArgumentParser
from pathlib import Path
from types import ModuleType
from typing import Any

Check warning on line 12 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L6-L12

Added lines #L6 - L12 were not covered by tests

import yaml
from fastapi import APIRouter

Check warning on line 15 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L14-L15

Added lines #L14 - L15 were not covered by tests

import murfey

Check warning on line 17 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L17

Added line #L17 was not covered by tests


def find_routers(name: str) -> dict[str, APIRouter]:

Check warning on line 20 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L20

Added line #L20 was not covered by tests

def _extract_routers_from_module(module: ModuleType):
routers = {}

Check warning on line 23 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L22-L23

Added lines #L22 - L23 were not covered by tests
for name, obj in inspect.getmembers(module):
if isinstance(obj, APIRouter):
module_path = module.__name__
key = f"{module_path}.{name}"
routers[key] = obj
return routers

Check warning on line 29 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L26-L29

Added lines #L26 - L29 were not covered by tests

routers = {}

Check warning on line 31 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L31

Added line #L31 was not covered by tests

# Import the module or package
try:
root = importlib.import_module(name)
except ImportError:
raise ImportError(

Check warning on line 37 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L34-L37

Added lines #L34 - L37 were not covered by tests
f"Cannot import '{name}'. Please ensure that you've installed all the "
"dependencies for the client, instrument server, and backend server "
"before running this command."
)

# If it's a package, walk through submodules and extract routers from each
if hasattr(root, "__path__"):
module_list = pkgutil.walk_packages(root.__path__, prefix=name + ".")

Check warning on line 45 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L45

Added line #L45 was not covered by tests
for _, module_name, _ in module_list:
try:
module = importlib.import_module(module_name)
except ImportError:
raise ImportError(

Check warning on line 50 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L47-L50

Added lines #L47 - L50 were not covered by tests
f"Cannot import '{module_name}'. Please ensure that you've "
"installed all the dependencies for the client, instrument "
"server, and backend server before running this command."
)

routers.update(_extract_routers_from_module(module))

Check warning on line 56 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L56

Added line #L56 was not covered by tests

# Extract directly from single module
else:
routers.update(_extract_routers_from_module(root))

Check warning on line 60 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L60

Added line #L60 was not covered by tests

return routers

Check warning on line 62 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L62

Added line #L62 was not covered by tests


def get_route_manifest(routers: dict[str, APIRouter]):

Check warning on line 65 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L65

Added line #L65 was not covered by tests

manifest = {}

Check warning on line 67 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L67

Added line #L67 was not covered by tests

for router_name, router in routers.items():
routes = []

Check warning on line 70 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L70

Added line #L70 was not covered by tests
for route in router.routes:
path_params = []

Check warning on line 72 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L72

Added line #L72 was not covered by tests
for param in route.dependant.path_params:
param_type = param.type_ if param.type_ is not None else Any
param_info = {

Check warning on line 75 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L74-L75

Added lines #L74 - L75 were not covered by tests
"name": param.name if hasattr(param, "name") else "",
"type": (
param_type.__name__
if hasattr(param_type, "__name__")
else str(param_type)
),
}
path_params.append(param_info)
route_info = {

Check warning on line 84 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L83-L84

Added lines #L83 - L84 were not covered by tests
"path": route.path if hasattr(route, "path") else "",
"function": route.name if hasattr(route, "name") else "",
"path_params": path_params,
"methods": list(route.methods) if hasattr(route, "methods") else [],
}
routes.append(route_info)
manifest[router_name] = routes
return manifest

Check warning on line 92 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L90-L92

Added lines #L90 - L92 were not covered by tests


def run():

Check warning on line 95 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L95

Added line #L95 was not covered by tests
# Set up additional args
parser = ArgumentParser()
parser.add_argument(

Check warning on line 98 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L97-L98

Added lines #L97 - L98 were not covered by tests
"--debug",
action="store_true",
default=False,
help=("Outputs the modules being inspected when creating the route manifest"),
)
args = parser.parse_args()

Check warning on line 104 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L104

Added line #L104 was not covered by tests

# Find routers
print("Finding routers...")
routers = {

Check warning on line 108 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L107-L108

Added lines #L107 - L108 were not covered by tests
**find_routers("murfey.instrument_server.api"),
**find_routers("murfey.server.api"),
}
# Generate the manifest
print("Extracting route information")
manifest = get_route_manifest(routers)

Check warning on line 114 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L113-L114

Added lines #L113 - L114 were not covered by tests

# Verify
if args.debug:
for router_name, routes in manifest.items():
print(f"Routes found in {router_name!r}")

Check warning on line 119 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L119

Added line #L119 was not covered by tests
for route in routes:
for key, value in route.items():
print(f"\t{key}: {value}")
print()

Check warning on line 123 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L122-L123

Added lines #L122 - L123 were not covered by tests

# Save the manifest
murfey_dir = Path(murfey.__path__[0])
manifest_file = murfey_dir / "util" / "route_manifest.yaml"
with open(manifest_file, "w") as file:
yaml.dump(manifest, file, default_flow_style=False, sort_keys=False)
print(

Check warning on line 130 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L126-L130

Added lines #L126 - L130 were not covered by tests
"Route manifest for instrument and backend servers saved to "
f"{str(manifest_file)!r}"
)
exit()

Check warning on line 134 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L134

Added line #L134 was not covered by tests


if __name__ == "__main__":
run()

Check warning on line 138 in src/murfey/cli/generate_route_manifest.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/generate_route_manifest.py#L138

Added line #L138 was not covered by tests
9 changes: 6 additions & 3 deletions src/murfey/cli/spa_ispyb_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
from sqlmodel import create_engine, select

from murfey.client.contexts.spa import _get_xml_list_index
from murfey.server import _murfey_id, _register
from murfey.server.feedback import _murfey_id, _register

Check warning on line 21 in src/murfey/cli/spa_ispyb_messages.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/spa_ispyb_messages.py#L21

Added line #L21 was not covered by tests
from murfey.server.ispyb import ISPyBSession, TransportManager, get_session_id
from murfey.server.murfey_db import url
from murfey.util import db
from murfey.util.api import url_path_for

Check warning on line 25 in src/murfey/cli/spa_ispyb_messages.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/spa_ispyb_messages.py#L25

Added line #L25 was not covered by tests
from murfey.util.config import get_machine_config, get_microscope, get_security_config


Expand Down Expand Up @@ -69,7 +70,7 @@
help="Path to directory containing image files",
)
parser.add_argument(
"--suffic",
"--suffix",
dest="suffix",
required=True,
type=str,
Expand Down Expand Up @@ -203,7 +204,9 @@
]
)
binning_factor = 1
server_config = requests.get(f"{args.url}/machine").json()
server_config = requests.get(

Check warning on line 207 in src/murfey/cli/spa_ispyb_messages.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/spa_ispyb_messages.py#L207

Added line #L207 was not covered by tests
f"{args.url}{url_path_for('session_control.router', 'machine_info_by_instrument', instrument_name=args.microscope)}"
).json()
if server_config.get("superres"):
# If camera is capable of superres and collection is in superres
binning_factor = 2
Expand Down
7 changes: 4 additions & 3 deletions src/murfey/cli/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import argparse
import subprocess
from pathlib import Path
from urllib.parse import urlparse
from urllib.parse import ParseResult, urlparse

Check warning on line 6 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L6

Added line #L6 was not covered by tests

import requests
from rich.console import Console
from rich.prompt import Confirm

from murfey.client import read_config
from murfey.util.api import url_path_for

Check warning on line 13 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L13

Added line #L13 was not covered by tests
from murfey.util.config import MachineConfig


Expand All @@ -35,11 +36,11 @@
args = parser.parse_args()

console = Console()
murfey_url = urlparse(args.server, allow_fragments=False)
murfey_url: ParseResult = urlparse(args.server, allow_fragments=False)

Check warning on line 39 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L39

Added line #L39 was not covered by tests

machine_data = MachineConfig(
requests.get(
f"{murfey_url.geturl()}/instruments/{instrument_name}/machine"
f"{murfey_url.geturl()}{url_path_for('session_control.router', 'machine_info_by_instrument', instrument_name=instrument_name)}"
).json()
)
if Path(args.source or ".").resolve() in machine_data.data_directories:
Expand Down
21 changes: 18 additions & 3 deletions src/murfey/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,26 @@
from murfey.client.instance_environment import MurfeyInstanceEnvironment
from murfey.client.tui.app import MurfeyTUI
from murfey.client.tui.status_bar import StatusBar
from murfey.util.client import _get_visit_list, authorised_requests, read_config
from murfey.util.api import url_path_for
from murfey.util.client import authorised_requests, read_config
from murfey.util.models import Visit

log = logging.getLogger("murfey.client")

requests.get, requests.post, requests.put, requests.delete = authorised_requests()


def _get_visit_list(api_base: ParseResult, instrument_name: str):
proxy_path = api_base.path.rstrip("/")
get_visits_url = api_base._replace(
path=f"{proxy_path}{url_path_for('session_control.router', 'get_current_visits', instrument_name=instrument_name)}"
)
server_reply = requests.get(get_visits_url.geturl())
if server_reply.status_code != 200:
raise ValueError(f"Server unreachable ({server_reply.status_code})")

Check warning on line 45 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L45

Added line #L45 was not covered by tests
return [Visit.parse_obj(v) for v in server_reply.json()]


def write_config(config: configparser.ConfigParser):
mcch = os.environ.get("MURFEY_CLIENT_CONFIG_HOME")
murfey_client_config_home = Path(mcch) if mcch else Path.home()
Expand Down Expand Up @@ -262,7 +275,9 @@
rich_handler.setLevel(logging.DEBUG if args.debug else logging.INFO)

# Set up websocket app and handler
client_id = requests.get(f"{murfey_url.geturl()}/new_client_id/").json()
client_id = requests.get(

Check warning on line 278 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L278

Added line #L278 was not covered by tests
f"{murfey_url.geturl()}{url_path_for('session_control.router', 'new_client_id')}"
).json()
ws = murfey.client.websocket.WSApp(
server=args.server,
id=client_id["new_id"],
Expand All @@ -279,7 +294,7 @@

# Load machine data for subsequent sections
machine_data = requests.get(
f"{murfey_url.geturl()}/instruments/{instrument_name}/machine"
f"{murfey_url.geturl()}{url_path_for('session_control.router', 'machine_info_by_instrument', instrument_name=instrument_name)}"
).json()
gain_ref: Path | None = None

Expand Down
3 changes: 3 additions & 0 deletions src/murfey/client/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def __init__(
else {}
)

def __repr__(self) -> str:
return f"<Analyser ({self._basepath})>"

def _find_extension(self, file_path: Path):
"""
Identifies the file extension and stores that information in the class.
Expand Down
Loading