Skip to content

Commit

Permalink
initial work on the new Job object
Browse files Browse the repository at this point in the history
  • Loading branch information
rozyczko committed Mar 27, 2024
1 parent 7c84e1e commit 3c53ff6
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 0 deletions.
36 changes: 36 additions & 0 deletions easyCore/Objects/Job/Analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 easyCore contributors <core@easyscience.software>
# SPDX-License-Identifier: BSD-3-Clause
# © 2021-2023 Contributors to the easyCore project <https://github.com/easyScience/easyCore

from easyCore.Objects.ObjectClasses import BaseObj
from easyCore.Objects.ObjectClasses import Parameter
from typing import Any, List

class AnalysisBase(BaseObj):
"""
This virtual class allows for the creation of technique-specific Analysis objects.
"""
def __init__(self, name: str, parameters: List[Parameter], *args, **kwargs):
super(AnalysisBase, self).__init__(name, *args, **kwargs)
self.parameters = parameters


# required dunder methods
def __str__(self):
return f"Analysis: {self.name}"

def __call__(self, *args: Any, **kwds: Any) -> Any:
return super().__call__(*args, **kwds)

def __copy__(self) -> 'AnalysisBase':
raise NotImplementedError("Copy not implemented")
#return super().__copy__()

def __deepcopy__(self, memo: Any) -> 'AnalysisBase':
raise NotImplementedError("Deepcopy not implemented")
#return super().__deepcopy__(memo)

def __eq__(self, other: Any) -> bool:
raise NotImplementedError("Equality not implemented")
#return super().__eq__(other)

36 changes: 36 additions & 0 deletions easyCore/Objects/Job/Experiment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 easyCore contributors <core@easyscience.software>
# SPDX-License-Identifier: BSD-3-Clause
# © 2021-2023 Contributors to the easyCore project <https://github.com/easyScience/easyCore

from easyCore.Objects.ObjectClasses import BaseObj
from easyCore.Objects.ObjectClasses import Parameter
from typing import Any, List

class ExperimentBase(BaseObj):
"""
This virtual class allows for the creation of technique-specific Experiment objects.
"""
def __init__(self, name: str, parameters: List[Parameter], *args, **kwargs):
super(ExperimentBase, self).__init__(name, *args, **kwargs)
self.parameters = parameters
self.name = name

# required dunder methods
def __str__(self):
return f"Experiment: {self.name}"

def __call__(self, *args: Any, **kwds: Any) -> Any:
return super().__call__(*args, **kwds)

def __copy__(self) -> 'ExperimentBase':
raise NotImplementedError("Copy not implemented")
#return super().__copy__()

def __deepcopy__(self, memo: Any) -> 'ExperimentBase':
raise NotImplementedError("Deepcopy not implemented")
#return super().__deepcopy__(memo)

def __eq__(self, other: Any) -> bool:
raise NotImplementedError("Equality not implemented")
#return super().__eq__(other)

55 changes: 55 additions & 0 deletions easyCore/Objects/Job/Job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: 2023 easyCore contributors <core@easyscience.software>
# SPDX-License-Identifier: BSD-3-Clause
# © 2021-2023 Contributors to the easyCore project <https://github.com/easyScience/easyCore

from easyCore.Objects.ObjectClasses import BaseObj
from easyCore.Objects.ObjectClasses import Parameter
from typing import List
from easyCore.Objects.Job.Theory import TheoryBase
from easyCore.Objects.Job.Experiment import ExperimentBase
from easyCore.Objects.Job.Analysis import AnalysisBase


class JobBase(BaseObj):
"""
This virtual class allows for the creation of technique-specific Job objects.
"""
def __init__(self, name: str, parameters: List[Parameter], *args, **kwargs):
super(JobBase, self).__init__(name, *args, **kwargs)
self.parameters = parameters
self._theory = None
self._experiment = None
self._analysis = None

"""
JobBase consists of Theory, Experiment, Analysis virtual classes.
"""
def set_theory(self, theory: TheoryBase):
# The implementation must include __copy__ and __deepcopy__ methods
raise NotImplementedError("setTheory not implemented")

def set_experiment(self, experiment: ExperimentBase):
# We might not have an experiment but this should be dealt with in the specific implementation
raise NotImplementedError("setExperiment not implemented")

def set_analysis(self, analysis: AnalysisBase):
raise NotImplementedError("setAnalysis not implemented")

@property
def theory(self):
return self._theory

@property
def experiment(self):
return self._experiment

@property
def analysis(self):
return self._analysis

def calculate_model(self, *args, **kwargs):
raise NotImplementedError("calculateModel not implemented")

def fit(self, *args, **kwargs):
raise NotImplementedError("fit not implemented")

36 changes: 36 additions & 0 deletions easyCore/Objects/Job/Theory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 easyCore contributors <core@easyscience.software>
# SPDX-License-Identifier: BSD-3-Clause
# © 2021-2023 Contributors to the easyCore project <https://github.com/easyScience/easyCore

from easyCore.Objects.ObjectClasses import BaseObj
from easyCore.Objects.ObjectClasses import Parameter
from typing import Any, List

class TheoryBase(BaseObj):
"""
This virtual class allows for the creation of technique-specific Theory objects.
"""
def __init__(self, name: str, parameters: List[Parameter], *args, **kwargs):
super(TheoryBase, self).__init__(name, *args, **kwargs)
self.parameters = parameters


# required dunder methods
def __str__(self):
return f"Theory: {self.name}"

def __call__(self, *args: Any, **kwds: Any) -> Any:
return super().__call__(*args, **kwds)

def __copy__(self) -> 'TheoryBase':
raise NotImplementedError("Copy not implemented")
#return super().__copy__()

def __deepcopy__(self, memo: Any) -> 'TheoryBase':
raise NotImplementedError("Deepcopy not implemented")
#return super().__deepcopy__(memo)

def __eq__(self, other: Any) -> bool:
raise NotImplementedError("Equality not implemented")
#return super().__eq__(other)

Empty file.

0 comments on commit 3c53ff6

Please sign in to comment.