Skip to content

Make XRD block natively multi-file#1868

Open
ml-evs wants to merge 1 commit into
mainfrom
ml-evs/xrd-multifile
Open

Make XRD block natively multi-file#1868
ml-evs wants to merge 1 commit into
mainfrom
ml-evs/xrd-multifile

Conversation

@ml-evs

@ml-evs ml-evs commented Jun 25, 2026

Copy link
Copy Markdown
Member

Removes the bodged version of multi-file XRD we added with "All compatible files" -- ready to be improved in the future...

@ml-evs ml-evs changed the title Make XRD block native multi-file Make XRD block natively multi-file Jun 25, 2026
@cypress

cypress Bot commented Jun 25, 2026

Copy link
Copy Markdown

datalab    Run #5149

Run Properties:  status check failed Failed #5149  •  git commit 611d453456 ℹ️: Merge d4c7cc8480dccaa04407baa2c55ce001bffd6050 into d15534e7199f4cf39ed37952b507...
Project datalab
Branch Review ml-evs/xrd-multifile
Run status status check failed Failed #5149
Run duration 24m 34s
Commit git commit 611d453456 ℹ️: Merge d4c7cc8480dccaa04407baa2c55ce001bffd6050 into d15534e7199f4cf39ed37952b507...
Committer Matthew Evans
View all properties for this run ↗︎

Test results
Tests that failed  Failures 8
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 530
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/editPage.cy.js • 4 failed tests • End-to-end tests (electron)

View Output

Test Artifacts
Edit Page > Uploads an XRD file, makes an XRD block and checks that the plot works Test Replay Screenshots
Edit Page > Uploads a fake PNG image, make a Media block and checks that the image is shown Test Replay Screenshots
Edit Page > Uploads a fake SVG, creates a Media block, and verifies sanitization Test Replay Screenshots
Edit Page > Uploads an Raman data file, makes a Raman block and checks that the plot is shown Test Replay Screenshots
Failed  cypress/e2e/editPage.cy.js • 4 failed tests • End-to-end tests (chrome)

View Output

Test Artifacts
Edit Page > Uploads an XRD file, makes an XRD block and checks that the plot works Test Replay Screenshots
Edit Page > Uploads a fake PNG image, make a Media block and checks that the image is shown Test Replay Screenshots
Edit Page > Uploads a fake SVG, creates a Media block, and verifies sanitization Test Replay Screenshots
Edit Page > Uploads an Raman data file, makes a Raman block and checks that the plot is shown Test Replay Screenshots

@ml-evs ml-evs added Python datablock An issue pertaining to a specific datablock labels Jun 26, 2026

@OMWalmsley OMWalmsley left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have not personally tested the PR yet, though here are some of my first code review comments.

Some possible changes you could make, mostly instances where you could remove continue to better highlight the control sequence of the code.

A couple to do with defining variables such as pattern_dfs which is defined twice, once with a type and once without a type (one of them is redundant, my suggestion would be to move the one with a type to the place where the one without the type currently resides).

They are all minor changes to improve readability and remove a tiny bit of redundancy.

)
except Exception as exc:
warnings.warn(f"Could not parse file {f['location']} as XRD data. Error: {exc}")
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could possibly remove this continue and add an else statement to the code after the try-except statement

file_info = get_file_info_by_id(f, update_if_live=False)
except OSError:
LOGGER.warning("Missing file found in database but no on disk: %s", f)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could remove continue and put code you expect to run after a successful try except in an else statement after the try and except

{"item_id": self.data["item_id"]},
projection={"file_ObjectIds": 1},
)
pattern_dfs: list[pd.DataFrame] = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You define this later in the file. Either this is redundant or because it has a defined type needs to replace the later definition

peak_data = {}
all_files = [{"location": filename, "immutable_id": filename} for filename in filenames]

pattern_dfs = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This was defined earlier... See previous comment

y_options: list[str] = []
for ind, f in enumerate(all_files):
try:
peak_data: dict = {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Value {} for peak_data is never used. Possibly could remove and just have the type definition, etc: peak_data : dict, or you could put a type definition on the next line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

datablock An issue pertaining to a specific datablock Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants