-
Notifications
You must be signed in to change notification settings - Fork 9
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
Package & Result additions #146
Conversation
* Make more intensive use of f-strings. * Implemented a Package.__repr__() method. * Added the "results" keyword to Package.__init__(); should take the pith the a pickled plams.Results instance (i.e. the .dill file). * Generalized the Package.__deepcopy__() so it'll also work on Package subclasses. * The Results-containing .dill file, which is contained within Pacakge.results, is automatically unpacked whenever getting Package.results or getting a non-existing attribute. Pacakge.results is henceforth replaced with the plams.Results object itself and all its non-magic/-private methods are added to the Pacakge instance as instance variables.
* Implemented compatiblity with 4e7dfc4 * Changed the "/" character with os.sep (important for Windows)
* Added type hints to all package modules. * Cleaned up some docstrings. * Removed empty prerun() and postrun() methods from Package subclasses; those are already defined in the superclass * Made Package a propert abstract base class Package.handle_special_keywords() and Package.run_job() abstract methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BvB93 Thank you for cleaning up the code! Really good work
super(ADF, self).__init__("adf") | ||
self.generic_dict_file = 'generic2ADF.json' | ||
|
||
def prerun(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for removing this kind of things!
@@ -55,31 +60,34 @@ def run_job(settings, mol, job_name='ADFjob', nproc=None): | |||
path_t21 = result._kf.path | |||
|
|||
# Relative path to the CWD | |||
relative_path_t21 = '/'.join(path_t21.split('/')[-3:]) | |||
relative_path_t21 = join(*str(path_t21).split(os.sep)[-3:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
'Package', 'run', 'registry', 'Result', | ||
'SerMolecule', 'SerSettings'] | ||
|
||
_BASE_PATH = Path('data') / 'dictionaries' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
} | ||
del _BASE_PATH | ||
|
||
WarnMap = Mapping[str, Type[Warning]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you really need a strong type language ;)
|
||
def __deepcopy__(self, memo: Any) -> 'Result': | ||
"""Return a deep copy of this instance.""" | ||
cls = type(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this!
work_dir {work_dir}\n | ||
""") | ||
|
||
@property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👊 awesome work!
@@ -337,28 +434,25 @@ def run(job, runner=None, path=None, folder=None, **kwargs): | |||
ret = call_default(job, kwargs.get('n_processes', 1), | |||
kwargs.get('always_cache', True)) | |||
else: | |||
raise "Don't know runner: {}".format(runner) | |||
raise ValueError(f"Don't know runner: {runner}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch!
Major
dill_path
keyword toPackage.__init__()
and it's subclasses. It should take the path to a pickledplams.Results
instance as value (i.e. the.dill
file) and store it in the newPackage.results
property.Pacakge.results
property, is automatically unpacked whenever gettingPackage.results
or getting a non-existing attribute.Pacakge.results
is henceforth replaced with theplams.Results
instance itself and all of its non-magic/non-private methods are added to thePacakge
as instance variables.For example:
Package.results
yields error an encountered.qmflows.packages
modules.Minor
.gitignore
with".spyproject/"
."/"
foros.sep
oros.path.join()
, improving compatibility with Windows.Package
and all its sub classes can handle file-like objects.Package.__repr__()
method.Package.__deepcopy__()
so it'll also work on all its subclasses.Package.prerun()
andPackage.postrun()
methods fromPackage
subclasses; these (empty) methods are now already defined in the superclass.find_file_pattern()
now always returns an iterator; changedparse_output_warnings()
to accommodate this change.Package
a proper abstract base class;Package.handle_special_keywords()
andPackage.run_job()
are now abstract methods.