Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve automatically context #29

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions src/pdi_nomad_plugin/general/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:
for sample in self.samples:
set_sample_status(
sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down Expand Up @@ -218,7 +217,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:
for sample in self.samples:
set_sample_status(
sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down Expand Up @@ -247,7 +245,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:
for sample in self.samples:
set_sample_status(
sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down Expand Up @@ -303,7 +300,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:
for sample in self.samples:
set_sample_status(
sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down Expand Up @@ -449,7 +445,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:
for sample in self.children_samples:
set_sample_status(
sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand All @@ -459,7 +454,6 @@ def normalize(self, archive, logger: 'BoundLogger') -> None:

set_sample_status(
self.parent_sample.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down
1 change: 0 additions & 1 deletion src/pdi_nomad_plugin/mbe/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@ def normalize(self, archive, logger):
if sample_holder_position.substrate:
set_sample_status(
sample_holder_position.substrate.reference,
archive.m_context,
logger,
as_delivered=False,
fresh=False,
Expand Down
17 changes: 16 additions & 1 deletion src/pdi_nomad_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def fetch_substrate(archive, sample_id, substrate_id, logger):

def set_sample_status(
sample_reference,
context,
logger,
*,
as_delivered=False,
Expand All @@ -316,6 +315,22 @@ def set_sample_status(
in the sample reference file.
The Sample archive file is then overwritten.
"""

from nomad.app.v1.routers.uploads import get_upload_with_read_access
from nomad.datamodel.context import ServerContext
from nomad.datamodel.data import User

context = ServerContext(
get_upload_with_read_access(
sample_reference.m_parent.metadata.m_context.upload_id,
User(
# is_admin=True,
user_id=sample_reference.m_parent.metadata.main_author.user_id,
),
include_others=True,
)
)

if sample_reference:
if (
hasattr(sample_reference, 'fresh')
Expand Down
Binary file modified tests/data/mbe/2023_06_12/MBE8_config.xlsx
Binary file not shown.