diff --git a/aiida_flexpart/parsers/collect_sens.py b/aiida_flexpart/parsers/collect_sens.py index 5b6c1ba..1f71e91 100644 --- a/aiida_flexpart/parsers/collect_sens.py +++ b/aiida_flexpart/parsers/collect_sens.py @@ -49,20 +49,13 @@ def parse(self, **kwargs): self.logger.error("Found files '{}', expected to find '{}'".format( files_retrieved, files_expected)) return self.exit_codes.ERROR_MISSING_OUTPUT_FILES - - nc_file_names = [i for i in files_retrieved if '.nc' in i] - with tempfile.TemporaryDirectory() as td: - self.retrieved.copy_tree(Path(td)) - for i in nc_file_names: - output_nc = NetCDF(Path(td)/i) - self.out(i,output_nc) # add output file self.logger.info(f"Parsing '{output_filename}'") with self.retrieved.open(output_filename, 'r') as handle: content = handle.read() output_node = SinglefileData(file=handle) - if 'CONGRATULATIONS' not in content: + if 'Writing' not in content: self.out('output_file', output_node) return ExitCode(1) diff --git a/aiida_flexpart/parsers/flexpart_post.py b/aiida_flexpart/parsers/flexpart_post.py index dc1e4bb..dce4b55 100644 --- a/aiida_flexpart/parsers/flexpart_post.py +++ b/aiida_flexpart/parsers/flexpart_post.py @@ -44,14 +44,7 @@ def parse(self, **kwargs): self.logger.error( f"Found files '{files_retrieved}', expected to find '{files_expected}'" ) - return self.exit_codes.ERROR_MISSING_OUTPUT_FILES - - nc_file_names = [i for i in files_retrieved if '.nc' in i] - with tempfile.TemporaryDirectory() as td: - self.retrieved.copy_tree(Path(td)) - for i in nc_file_names: - output_nc = NetCDF(Path(td)/i) - self.out(i,output_nc) + return self.exit_codes.ERROR_MISSING_OUTPUT_FILES # add output file self.logger.info(f"Parsing '{output_filename}'") diff --git a/aiida_flexpart/workflows/inspect.py b/aiida_flexpart/workflows/inspect.py index b6333d0..de3026c 100644 --- a/aiida_flexpart/workflows/inspect.py +++ b/aiida_flexpart/workflows/inspect.py @@ -7,6 +7,11 @@ NetCDF = DataFactory("netcdf.data") def check(nc_file): + """ + Checks if there is a netcdf file stored with the same name, + if so, it checks the created date, if that is a match then returns + False. + """ qb = orm.QueryBuilder() qb.append( NetCDF, @@ -35,26 +40,20 @@ class InspectWorkflow(WorkChain): @classmethod def define(cls, spec): super().define(spec) - spec.input('remotes',valid_type=orm.RemoteData,required=False) - spec.input_namespace('remotes_cs', valid_type=orm.RemoteStashFolderData, required=False) + spec.input_namespace('remotes',valid_type=orm.RemoteData,required=False) spec.outputs.dynamic = True spec.outline( cls.inspect, - cls.save_file, cls.results, ) def inspect(self): - self.ctx.list_files = [] - if 'remotes' in self.inputs: - for i in self.inputs.remotes.listdir()[:10]: - if '.nc' in i: - self.ctx.list_files.append(i) - - def save_file(self): - for i in self.ctx.list_files: - self.report(f'processing {i}') - store(i,self.inputs.remotes) - + self.ctx.list_files = [] + for v in self.inputs.remotes.values(): + for i in v.listdir(): + if '.nc' in i: + self.ctx.list_files.append(i) + store(i,v) + def results(self): self.out('result', self.ctx.list_files) \ No newline at end of file