Skip to content

Commit

Permalink
DevOps: Add AIIDA_WARN_V3 environment variable to CI (#836)
Browse files Browse the repository at this point in the history
This will enable deprecation warnings so that they can easily be
addressed in the code. All deprecated code has been replaced.
  • Loading branch information
ramirezfranciscof authored Sep 5, 2022
1 parent 9364af4 commit fc35d8a
Show file tree
Hide file tree
Showing 46 changed files with 209 additions and 192 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ jobs:
run: pip install -e .[tests]

- name: Run pytest
env:
AIIDA_WARN_v3: 1
run: pytest -sv tests
2 changes: 2 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- name: Run pytest
id: tests
env:
AIIDA_WARN_v3: 1
run: pytest -sv tests

- name: Slack notification
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/calculations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def _generate_PWCPinputdata(cls, parameters, settings, pseudos, structure, kpoin
try:
structure_parameters = get_parameters_from_cell(
ibrav=ibrav,
cell=structure.get_attribute('cell'),
cell=structure.base.attributes.get('cell'),
tolerance=settings.pop('IBRAV_CELL_TOLERANCE', 1e-6)
)
except ValueError as exc:
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/calculations/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def prepare_for_submission(self, folder):
settings = {}

parent_folder = self.inputs.parent_folder
parent_calcs = parent_folder.get_incoming(node_class=orm.CalcJobNode).all()
parent_calcs = parent_folder.base.links.get_incoming(node_class=orm.CalcJobNode).all()

if not parent_calcs:
raise exceptions.NotExistent(f'parent_folder<{parent_folder.pk}> has no parent calculation')
Expand Down
16 changes: 8 additions & 8 deletions src/aiida_quantumespresso/calculations/pwimmigrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class or using the ``set_`` methods (e.g. ``set_remote_workdir``).
if settings_dict:
self.use_settings(Dict(settings_dict))

self.set_attribute('input_nodes_created', True)
self.base.attributes.set('input_nodes_created', True)

def _prepare_for_retrieval(self, open_transport):
"""Prepare the calculation for retrieval by daemon.
Expand All @@ -322,8 +322,8 @@ def _prepare_for_retrieval(self, open_transport):
# Manually set the files that will be copied to the repository and that
# the parser will extract the results from. This would normally be
# performed in self._prepare_for_submission prior to submission.
self.set_attribute('retrieve_list', [self._OUTPUT_FILE_NAME] + self.xml_filenames)
self.set_attribute('retrieve_singlefile_list', [])
self.base.attributes.set('retrieve_list', [self._OUTPUT_FILE_NAME] + self.xml_filenames)
self.base.attributes.set('retrieve_singlefile_list', [])

# Make sure the calculation and input links are stored.
self.store_all()
Expand Down Expand Up @@ -403,7 +403,7 @@ def set_remote_workdir(self, remote_workdir):
"""
# This is the functionality as self._set_remote_workir, but it bypasses
# the need to have the calculation state set as SUBMITTING.
self.set_attribute('remote_workdir', remote_workdir)
self.base.attributes.set('remote_workdir', remote_workdir)

def set_output_subfolder(self, output_subfolder):
"""Manually set the job's ``outdir`` variable (e.g. ``'./out/'``).
Expand Down Expand Up @@ -469,28 +469,28 @@ def _OUTPUT_SUBFOLDER(self):

@_OUTPUT_SUBFOLDER.setter
def _OUTPUT_SUBFOLDER(self, value):
self.set_attribute('output_subfolder', value)
self.base.attributes.set('output_subfolder', value)

@property
def _PREFIX(self):
return self.get_attr('prefix', None)

@_PREFIX.setter
def _PREFIX(self, value):
self.set_attribute('prefix', value)
self.base.attributes.set('prefix', value)

@property
def _INPUT_FILE_NAME(self):
return self.get_attr('input_file_name', None)

@_INPUT_FILE_NAME.setter
def _INPUT_FILE_NAME(self, value):
self.set_attribute('input_file_name', value)
self.base.attributes.set('input_file_name', value)

@property
def _OUTPUT_FILE_NAME(self):
return self.get_attr('output_file_name', None)

@_OUTPUT_FILE_NAME.setter
def _OUTPUT_FILE_NAME(self, value):
self.set_attribute('output_file_name', value)
self.base.attributes.set('output_file_name', value)
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/calculations/xspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from aiida_quantumespresso.calculations.namelists import NamelistsCalculation

KpointsData = DataFactory('array.kpoints')
KpointsData = DataFactory('core.array.kpoints')


class XspectraCalculation(NamelistsCalculation):
Expand Down
3 changes: 2 additions & 1 deletion src/aiida_quantumespresso/cli/calculations/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def launch_calculation(code, calculation, max_num_machines, max_wallclock_second
raise click.BadParameter(
f'input calculation node has process_type: {calculation.process_type}; should be {expected_process_type}'
)
parent_folder = calculation.get_outgoing(node_class=RemoteData, link_label_filter='remote_folder').one().node
parent_folder = calculation.base.links.get_outgoing(node_class=RemoteData,
link_label_filter='remote_folder').one().node

inputs = {
'code': code,
Expand Down
8 changes: 5 additions & 3 deletions src/aiida_quantumespresso/cli/calculations/epw.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ def launch_calculation(
f'--pw-nscf-parent node has process_type: {pw_nscf_parent.process_type}; should be {expected_process_type}'
)

pw_nscf_parent_folder = pw_nscf_parent.get_outgoing(node_class=orm.RemoteData,
link_label_filter='remote_folder').one().node
pw_nscf_parent_folder = pw_nscf_parent.base.links.get_outgoing(
node_class=orm.RemoteData, link_label_filter='remote_folder'
).one().node

expected_process_type = 'aiida.calculations:quantumespresso.ph'
if ph_parent.process_type != expected_process_type:
raise click.BadParameter(
f'--ph-parent has process_type: {ph_parent.process_type}; should be {expected_process_type}'
)

ph_parent_folder = ph_parent.get_outgoing(node_class=orm.RemoteData, link_label_filter='remote_folder').one().node
ph_parent_folder = ph_parent.base.links.get_outgoing(node_class=orm.RemoteData,
link_label_filter='remote_folder').one().node

parameters = {
'INPUTEPW': {
Expand Down
3 changes: 2 additions & 1 deletion src/aiida_quantumespresso/cli/calculations/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def launch_calculation(code, kpoints_mesh, calculation, max_num_machines, max_wa
f'input calculation node has process_type: {calculation.process_type}; should be {expected_process_type}'
)

parent_folder = calculation.get_outgoing(node_class=orm.RemoteData, link_label_filter='remote_folder').one().node
parent_folder = calculation.base.links.get_outgoing(node_class=orm.RemoteData,
link_label_filter='remote_folder').one().node

inputs = {
'code': code,
Expand Down
3 changes: 2 additions & 1 deletion src/aiida_quantumespresso/cli/calculations/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def launch_calculation(code, calculation, max_num_machines, max_wallclock_second
f'input calculation node has process_type: {calculation.process_type}; should be {expected_process_type}'
)

parent_folder = calculation.get_outgoing(node_class=orm.RemoteData, link_label_filter='remote_folder').one().node
parent_folder = calculation.base.links.get_outgoing(node_class=orm.RemoteData,
link_label_filter='remote_folder').one().node

inputs = {
'code': code,
Expand Down
3 changes: 2 additions & 1 deletion src/aiida_quantumespresso/cli/calculations/projwfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def launch_calculation(code, calculation, max_num_machines, max_wallclock_second
raise click.BadParameter(
f'input calculation node has process_type: {calculation.process_type}; should be {expected_process_type}'
)
parent_folder = calculation.get_outgoing(node_class=RemoteData, link_label_filter='remote_folder').one().node
parent_folder = calculation.base.links.get_outgoing(node_class=RemoteData,
link_label_filter='remote_folder').one().node

inputs = {
'code': code,
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/cli/utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def echo_process_results(node):
from aiida.common.links import LinkType

class_name = node.process_class.__name__
outputs = node.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN)).all()
outputs = node.base.links.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN)).all()

if hasattr(node, 'dry_run_info'):
# It is a dry-run: get the information and print it
Expand Down
18 changes: 9 additions & 9 deletions src/aiida_quantumespresso/data/force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,71 @@ def set_file(self, file, filename=None, **kwargs):

# Add all other attributes found in the parsed dictionary
for key, value in dictionary.items():
self.set_attribute(key, value)
self.base.attributes.set(key, value)

@property
def number_of_species(self):
"""Return the number of atom species.
:return: a scalar
"""
return self.get_attribute('number_of_species')
return self.base.attributes.get('number_of_species')

@property
def number_of_atoms(self):
"""Return the number of atoms.
:return: a scalar
"""
return self.get_attribute('number_of_atoms')
return self.base.attributes.get('number_of_atoms')

@property
def cell(self):
"""Return the crystal unit cell where rows are the crystal vectors.
:return: a 3x3 numpy.array
"""
return numpy.array(self.get_attribute('cell'))
return numpy.array(self.base.attributes.get('cell'))

@property
def atom_list(self):
"""Return the list of atoms.
:return: a list of length-5 tuple (element name, element mass amu_ry, 3 coordinates in cartesian Angstrom)
"""
return self.get_attribute('atom_list')
return self.base.attributes.get('atom_list')

@property
def has_done_electric_field(self):
"""Return flag to indicate if dielectric tensor and effective charges were computed.
:return: a boolean
"""
return self.get_attribute('has_done_electric_field')
return self.base.attributes.get('has_done_electric_field')

@property
def dielectric_tensor(self):
"""Return the dielectric tensor matrix.
:return: a 3x3 tuple
"""
return self.get_attribute('dielectric_tensor')
return self.base.attributes.get('dielectric_tensor')

@property
def effective_charges_eu(self):
"""Return the effective charges for each atom.
:return: a list of number_of_atoms elements, each being a 3x3 tuple
"""
return self.get_attribute('effective_charges_eu')
return self.base.attributes.get('effective_charges_eu')

@property
def qpoints_mesh(self):
"""Return the number of q-points in each direction.
:return: a length-3 tuple
"""
return tuple(self.get_attribute('qpoints_mesh'))
return tuple(self.base.attributes.get('qpoints_mesh'))


def parse_q2r_force_constants_file(lines, also_force_constants=False):
Expand Down
14 changes: 7 additions & 7 deletions src/aiida_quantumespresso/parsers/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def parse(self, **kwargs):
retrieved = self.retrieved

# check what is inside the folder
list_of_files = retrieved.list_object_names()
list_of_files = retrieved.base.repository.list_object_names()

# options.metadata become attributes like this:
stdout_filename = self.node.get_attribute('output_filename')
stdout_filename = self.node.base.attributes.get('output_filename')
# at least the stdout should exist
if stdout_filename not in list_of_files:
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_READ)
Expand Down Expand Up @@ -63,9 +63,9 @@ def parse(self, **kwargs):
self.logger.info('print counter in xml format')
filename_counter = filename_counter_xml

output_stdout = retrieved.get_object_content(stdout_filename)
output_xml = retrieved.get_object_content(xml_files[0])
output_xml_counter = None if no_trajectory_output else retrieved.get_object_content(filename_counter)
output_stdout = retrieved.base.repository.get_object_content(stdout_filename)
output_xml = retrieved.base.repository.get_object_content(xml_files[0])
output_xml_counter = None if no_trajectory_output else retrieved.base.repository.get_object_content(filename_counter)
out_dict, _raw_successful = parse_cp_raw_output(
output_stdout, output_xml, output_xml_counter, print_counter_xml
)
Expand Down Expand Up @@ -115,7 +115,7 @@ def parse(self, **kwargs):

for name, extension, scale, elements in trajectories:
try:
with retrieved.open(f'{self.node.process_class._PREFIX}.{extension}') as datafile:
with retrieved.base.repository.open(f'{self.node.process_class._PREFIX}.{extension}') as datafile:
data = [l.split() for l in datafile]
# POSITIONS stored in angstrom
traj_data = parse_cp_traj_stanzas(
Expand All @@ -138,7 +138,7 @@ def parse(self, **kwargs):

# =============== EVP trajectory ============================
try:
with retrieved.open(f'{self._node.process_class._PREFIX}.evp') as handle:
with retrieved.base.repository.open(f'{self._node.process_class._PREFIX}.evp') as handle:
matrix = numpy.genfromtxt(handle)
# there might be a different format if the matrix has one row only
try:
Expand Down
4 changes: 2 additions & 2 deletions src/aiida_quantumespresso/parsers/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def parse(self, **kwargs):
# Read standard out
try:
filename_stdout = self.node.get_option('output_filename') # or get_attribute(), but this is clearer
with retrieved.open(filename_stdout, 'r') as fil:
with retrieved.base.repository.open(filename_stdout, 'r') as fil:
out_file = fil.readlines()
except OSError:
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_READ)
Expand All @@ -37,7 +37,7 @@ def parse(self, **kwargs):

# check that the dos file is present, if it is, read it
try:
with retrieved.open(self.node.process_class._DOS_FILENAME, 'r') as fil:
with retrieved.base.repository.open(self.node.process_class._DOS_FILENAME, 'r') as fil:
dos_file = fil.readlines()
except OSError:
return self.exit(self.exit_codes.ERROR_READING_DOS_FILE)
Expand Down
8 changes: 4 additions & 4 deletions src/aiida_quantumespresso/parsers/matdyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def parse(self, **kwargs):
filename_stdout = self.node.get_option('output_filename')
filename_frequencies = MatdynCalculation._PHONON_FREQUENCIES_NAME

if filename_stdout not in retrieved.list_object_names():
if filename_stdout not in retrieved.base.repository.list_object_names():
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_READ)

if 'JOB DONE' not in retrieved.get_object_content(filename_stdout):
if 'JOB DONE' not in retrieved.base.repository.get_object_content(filename_stdout):
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE)

if filename_frequencies not in retrieved.list_object_names():
if filename_frequencies not in retrieved.base.repository.list_object_names():
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_READ)

# Extract the kpoints from the input data and create the `KpointsData` for the `BandsData`
Expand All @@ -34,7 +34,7 @@ def parse(self, **kwargs):
kpoints_for_bands = orm.KpointsData()
kpoints_for_bands.set_kpoints(kpoints)

parsed_data = parse_raw_matdyn_phonon_file(retrieved.get_object_content(filename_frequencies))
parsed_data = parse_raw_matdyn_phonon_file(retrieved.base.repository.get_object_content(filename_frequencies))

try:
num_kpoints = parsed_data.pop('num_kpoints')
Expand Down
Loading

0 comments on commit fc35d8a

Please sign in to comment.