Commit ce6c2ea6 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added raw_id parsing. #218

parent f022653a
Pipeline #61678 passed with stages
in 18 minutes and 58 seconds
Subproject commit 2ac8d8e0292d3a233f331e9c76739174482568e5
Subproject commit c36949f0c8421fff340d314d16ee83f7da5974ac
Subproject commit 217239fb03e57ee84431d16ebaa99fc058dac62d
Subproject commit c14a0bc535aa8a7bbae64b565d6f7f61d3b5515d
......@@ -83,6 +83,7 @@ class CalcWithMetadata(Mapping):
self.calc_hash: str = None
self.mainfile: str = None
self.pid: int = None
self.raw_id: str = None
# basic upload and processing related metadata
self.upload_time: datetime.datetime = None
......@@ -294,6 +295,7 @@ class Domain:
upload_id=DomainQuantity(description='Search for the upload_id.'),
calc_id=DomainQuantity(description='Search for the calc_id.'),
pid=DomainQuantity(description='Search for the pid.'),
raw_id=DomainQuantity(description='Search for the raw_id.'),
mainfile=DomainQuantity(description='Search for the mainfile.'),
external_id=DomainQuantity(description='External user provided id. Does not have to be unique necessarily.'),
dataset=DomainQuantity(
......
......@@ -114,6 +114,8 @@ class DFTCalcWithMetadata(CalcWithMetadata):
except KeyError:
self.code_version = config.services.unavailable_value
self.raw_id = get_optional_backend_value(backend, 'raw_id', 'section_run', 0)
self.atoms = get_optional_backend_value(backend, 'atom_labels', 'section_system', [], logger=logger)
if hasattr(self.atoms, 'tolist'):
self.atoms = self.atoms.tolist()
......
......@@ -113,6 +113,7 @@ class Entry(Document, metaclass=WithDomain):
calc_id = Keyword()
calc_hash = Keyword()
pid = Keyword()
raw_id = Keyword()
mainfile = Keyword()
files = Text(multi=True, analyzer=path_analyzer, fields={'keyword': Keyword()})
uploader = Object(User)
......@@ -144,6 +145,7 @@ class Entry(Document, metaclass=WithDomain):
self.calc_id = source.calc_id
self.calc_hash = source.calc_hash
self.pid = None if source.pid is None else str(source.pid)
self.raw_id = None if source.raw_id is None else str(source.raw_id)
self.processed = source.processed
self.last_processing = source.last_processing
......
......@@ -36,6 +36,7 @@ from tests.test_files import example_file, example_file_mainfile, example_file_c
from tests.test_files import create_staging_upload, create_public_upload, assert_upload_files
from tests.test_coe_repo import assert_coe_upload
from tests.test_search import assert_search_upload
from tests.processing import test_data as test_processing
from tests.app.test_app import BlueprintClient
......@@ -972,6 +973,20 @@ class TestRepo():
assert json.loads(rv.data)['calc_id'] == '%d' % pid
assert json.loads(rv.data)['upload_id'] == '0'
@pytest.mark.timeout(config.tests.default_timeout)
def test_raw_id(self, api, test_user, test_user_auth, proc_infra):
example_upload_file = 'tests/data/proc/with_raw_id.zip'
example_upload_id = os.path.basename(example_upload_file).replace('.zip', '')
test_processing.run_processing((example_upload_id, example_upload_file), test_user)
rv = api.get(
'/repo/?%s' % urlencode(dict(owner='all', raw_id='C61A2F88-A0EA-4F0B-AA47-A715868B2E26')),
headers=test_user_auth)
assert rv.status_code == 200
data = json.loads(rv.data)
assert data['pagination']['total'] == 1
assert data['results'][0]['raw_id'] == 'C61A2F88-A0EA-4F0B-AA47-A715868B2E26'
class TestRaw(UploadFilesBasedTests):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment