Skip to content

Conversation

@summerhenson
Copy link

Database backend in progress.

Copy link
Collaborator

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

In addition to my inline comments, a few general notes:

  • I said this in the meeting, but wanted to reiterate it - good use of atomic commits with specific commit messages
  • Some python formatting would be useful. Running everything through ruff could be worthwhile.
  • Relative imports can be fragile, but mostly when trying to run a python file directly. That isn't easy with Django, so it's not that huge an issue, but wanted to mention it.
  • Another thing we discussed at today's meeting, but wanted to mention again, is user auth and request.user clashes. Many of the checks don't ensure the authenticated user is the data owner.

Overall, a good start to the project. I'll try to make comments every week, or as updates are made.

@summerhenson summerhenson force-pushed the sasview-database branch 2 times, most recently from 6503450 to c0c7fa0 Compare March 19, 2025 20:21
Comment on lines +10 to +14
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
files: "sasdata/fair_database/.*"
- id: ruff-format
files: "sasdata/fair_database/.*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

def parse(unit_string: str) -> "Unit":
pass

def serialise_json(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this get extended to Child classes as well?

Copy link
Author

Choose a reason for hiding this comment

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

I believe that was the idea, but on a second look it might make more sense to just use the string representation of a unit for serialization.


QuantityType = TypeVar("QuantityType")

# TODO: figure out how to handle np.ndarray serialization (save as file or otherwise)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Wouldn't there be a security issue with pickle?


# data contents - maybe ManyToManyField
data_contents = models.ManyToManyField("Quantity", through="LabeledQuantity")
data_contents = models.ManyToManyField("Quantity")
Copy link

Choose a reason for hiding this comment

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

Maybe I am missing something, but to reduce complexity, I would suggest starting with data_contents as a OneToManyField. We can reduce storage by allowing a quantity to belong to multiple data sets, but I think it will be cleaner and simpler to manage if every data set has its own data contents.


# dataset
# dataset = models.ManyToManyField(DataSet)
dataset = models.ManyToManyField(DataSet)
Copy link

Choose a reason for hiding this comment

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

Same question here, should we for simplicity say that a data set can only belong to one session? These are things we can discuss.

dataset = models.ForeignKey(
DataSet, on_delete=models.CASCADE, related_name="data_contents"
)

Choose a reason for hiding this comment

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

This is the right way to connect Quantity to DataSet and better than my suggestion 👌

operation_tree = models.OneToOneField(
"OperationTree", blank=True, null=True, on_delete=models.SET_NULL
)

Choose a reason for hiding this comment

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

I saw your comment/question about how deleting an OperationTree should work. I think cascade delete would handle this automatically if OperationTree had Quantity as an optional foreign key with on_delete=models.CASCADE, and the same for the foreign key to the parent operation.

Copy link
Collaborator

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

Some more nitpicking 😉

@backmari
Copy link

If there are no more planned changes to the models, maybe we should delete the migrations and create new initial migrations based on the current state of the models. It definitely made sense to keep all intermediate migrations while the models were being developed, but this is probably a good place to start fresh.

jamescrake-merani and others added 25 commits July 7, 2025 12:14
Update the ASCII reader to import raw metadata
Applies automatic fixes from the default ruff ruleset
This is a bit of a bodge for now, but a more permanent fix will be
applied in the unit test refactor.
@DrPaulSharp DrPaulSharp force-pushed the refactor_24 branch 2 times, most recently from a16b0a6 to e27d0cc Compare August 11, 2025 15:43
@DrPaulSharp DrPaulSharp force-pushed the refactor_24 branch 2 times, most recently from d4683bd to 3df6e01 Compare November 7, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants