pyfemtet 0.6.6__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyfemtet might be problematic. Click here for more details.
- pyfemtet/__init__.py +1 -1
- pyfemtet/_femtet_config_util/exit.py +3 -2
- pyfemtet/_util/dask_util.py +10 -0
- pyfemtet/_util/excel_macro_util.py +25 -16
- pyfemtet/dispatch_extensions/__init__.py +0 -1
- pyfemtet/dispatch_extensions/_impl.py +2 -5
- pyfemtet/logger/__init__.py +21 -2
- pyfemtet/logger/_impl.py +189 -65
- pyfemtet/opt/_femopt.py +27 -17
- pyfemtet/opt/_femopt_core.py +36 -30
- pyfemtet/opt/_test_utils/control_femtet.py +0 -6
- pyfemtet/opt/interface/__init__.py +1 -1
- pyfemtet/opt/interface/_base.py +2 -4
- pyfemtet/opt/interface/_excel_interface.py +433 -104
- pyfemtet/opt/interface/_femtet.py +14 -21
- pyfemtet/opt/interface/_femtet_parametric.py +1 -1
- pyfemtet/opt/interface/_femtet_with_nx/_interface.py +1 -1
- pyfemtet/opt/interface/_femtet_with_sldworks.py +1 -1
- pyfemtet/opt/optimizer/_base.py +5 -5
- pyfemtet/opt/optimizer/_optuna/_botorch_patch/enable_nonlinear_constraint.py +4 -1
- pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +0 -1
- pyfemtet/opt/visualization/_base.py +4 -4
- {pyfemtet-0.6.6.dist-info → pyfemtet-0.7.1.dist-info}/METADATA +2 -1
- {pyfemtet-0.6.6.dist-info → pyfemtet-0.7.1.dist-info}/RECORD +27 -26
- {pyfemtet-0.6.6.dist-info → pyfemtet-0.7.1.dist-info}/LICENSE +0 -0
- {pyfemtet-0.6.6.dist-info → pyfemtet-0.7.1.dist-info}/WHEEL +0 -0
- {pyfemtet-0.6.6.dist-info → pyfemtet-0.7.1.dist-info}/entry_points.txt +0 -0
pyfemtet/opt/_femopt_core.py
CHANGED
|
@@ -22,7 +22,7 @@ if version.parse(optuna.version.__version__) < version.parse('4.0.0'):
|
|
|
22
22
|
else:
|
|
23
23
|
from optuna._hypervolume import wfg
|
|
24
24
|
compute_hypervolume = wfg.compute_hypervolume
|
|
25
|
-
from dask.distributed import Lock, get_client
|
|
25
|
+
from dask.distributed import Lock, get_client, Client
|
|
26
26
|
|
|
27
27
|
# win32com
|
|
28
28
|
from win32com.client import constants, Constants
|
|
@@ -32,10 +32,9 @@ from pyfemtet.opt.interface import FEMInterface, FemtetInterface
|
|
|
32
32
|
from pyfemtet._message import encoding, Msg
|
|
33
33
|
|
|
34
34
|
# logger
|
|
35
|
-
import
|
|
36
|
-
|
|
37
|
-
logger =
|
|
38
|
-
logger.setLevel(logging.INFO)
|
|
35
|
+
from pyfemtet.logger import get_module_logger
|
|
36
|
+
|
|
37
|
+
logger = get_module_logger('opt.core', __name__)
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
__all__ = [
|
|
@@ -503,19 +502,6 @@ class ObjectivesFunc:
|
|
|
503
502
|
return f
|
|
504
503
|
|
|
505
504
|
|
|
506
|
-
class _HistoryDfCore:
|
|
507
|
-
"""Class for managing a DataFrame object in a distributed manner."""
|
|
508
|
-
|
|
509
|
-
def __init__(self):
|
|
510
|
-
self.df = pd.DataFrame()
|
|
511
|
-
|
|
512
|
-
def set_df(self, df):
|
|
513
|
-
self.df = df
|
|
514
|
-
|
|
515
|
-
def get_df(self):
|
|
516
|
-
return self.df
|
|
517
|
-
|
|
518
|
-
|
|
519
505
|
class History:
|
|
520
506
|
"""Class for managing the history of optimization results.
|
|
521
507
|
|
|
@@ -543,8 +529,6 @@ class History:
|
|
|
543
529
|
is_restart = False
|
|
544
530
|
is_processing = False
|
|
545
531
|
_df = None # in case without client
|
|
546
|
-
_future = None # in case with client
|
|
547
|
-
_actor_data = None # in case with client
|
|
548
532
|
|
|
549
533
|
def __init__(
|
|
550
534
|
self,
|
|
@@ -565,6 +549,7 @@ class History:
|
|
|
565
549
|
self.obj_names = obj_names
|
|
566
550
|
self.cns_names = cns_names
|
|
567
551
|
self.additional_metadata = additional_metadata or ''
|
|
552
|
+
self.__scheduler_address = client.scheduler.address if client is not None else None
|
|
568
553
|
|
|
569
554
|
# 最適化実行中かどうか
|
|
570
555
|
self.is_processing = client is not None
|
|
@@ -572,10 +557,6 @@ class History:
|
|
|
572
557
|
# 最適化実行中の process monitor である場合
|
|
573
558
|
if self.is_processing:
|
|
574
559
|
|
|
575
|
-
# actor の生成
|
|
576
|
-
self._future = client.submit(_HistoryDfCore, actor=True)
|
|
577
|
-
self._actor_data = self._future.result()
|
|
578
|
-
|
|
579
560
|
# csv が存在すれば続きからモード
|
|
580
561
|
self.is_restart = os.path.isfile(self.path)
|
|
581
562
|
|
|
@@ -641,16 +622,36 @@ class History:
|
|
|
641
622
|
self.set_df(df)
|
|
642
623
|
|
|
643
624
|
def get_df(self) -> pd.DataFrame:
|
|
644
|
-
if self.
|
|
625
|
+
if self.__scheduler_address is None:
|
|
645
626
|
return self._df
|
|
646
627
|
else:
|
|
647
|
-
|
|
628
|
+
# scheduler がまだ存命か確認する
|
|
629
|
+
try:
|
|
630
|
+
with Lock('access-df'):
|
|
631
|
+
client_: 'Client' = get_client(self.__scheduler_address)
|
|
632
|
+
if 'df' in client_.list_datasets():
|
|
633
|
+
return client_.get_dataset('df')
|
|
634
|
+
else:
|
|
635
|
+
logger.debug('Access df of History before it is initialized.')
|
|
636
|
+
return pd.DataFrame()
|
|
637
|
+
except OSError:
|
|
638
|
+
logger.error('Scheduler is already dead. Most frequent reasen to show this message is that the pyfemtet monitor UI is not refreshed even if the main optimization process is terminated.')
|
|
639
|
+
return pd.DataFrame()
|
|
648
640
|
|
|
649
641
|
def set_df(self, df: pd.DataFrame):
|
|
650
|
-
if self.
|
|
642
|
+
if self.__scheduler_address is None:
|
|
651
643
|
self._df = df
|
|
652
644
|
else:
|
|
653
|
-
|
|
645
|
+
try:
|
|
646
|
+
with Lock('access-df'):
|
|
647
|
+
client_: 'Client' = get_client(self.__scheduler_address)
|
|
648
|
+
if 'df' in client_.list_datasets():
|
|
649
|
+
client_.unpublish_dataset('df') # 更新する場合は前もって削除が必要、本来は dask collection をここに入れる使い方をする。
|
|
650
|
+
client_.publish_dataset(**dict(
|
|
651
|
+
df=df
|
|
652
|
+
))
|
|
653
|
+
except OSError:
|
|
654
|
+
logger.error('Scheduler is already dead. Most frequent reasen to show this message is that the pyfemtet monitor UI is not refreshed even if the main optimization process is terminated.')
|
|
654
655
|
|
|
655
656
|
def create_df_columns(self):
|
|
656
657
|
"""Create columns of history."""
|
|
@@ -979,8 +980,13 @@ class OptimizationStatus:
|
|
|
979
980
|
TERMINATE_ALL = 60
|
|
980
981
|
CRASHED = 70
|
|
981
982
|
|
|
982
|
-
def __init__(self, client, name='entire'):
|
|
983
|
-
self._future = client.submit(
|
|
983
|
+
def __init__(self, client, worker_address, name='entire'):
|
|
984
|
+
self._future = client.submit(
|
|
985
|
+
_OptimizationStatusActor,
|
|
986
|
+
actor=True,
|
|
987
|
+
workers=[worker_address],
|
|
988
|
+
allow_other_workers=False,
|
|
989
|
+
)
|
|
984
990
|
self._actor = self._future.result()
|
|
985
991
|
self.name = name
|
|
986
992
|
self.set(self.INITIALIZING)
|
|
@@ -5,12 +5,6 @@ from tqdm import tqdm
|
|
|
5
5
|
from win32com.client import Dispatch
|
|
6
6
|
from femtetutils import util
|
|
7
7
|
|
|
8
|
-
import logging
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
logger = logging.getLogger("test")
|
|
12
|
-
logger.setLevel(logging.DEBUG)
|
|
13
|
-
|
|
14
8
|
|
|
15
9
|
def _open_femprj(femprj_path):
|
|
16
10
|
Femtet = Dispatch("FemtetMacro.Femtet")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from pyfemtet.opt.interface._base import FEMInterface
|
|
1
|
+
from pyfemtet.opt.interface._base import FEMInterface
|
|
2
2
|
from pyfemtet.opt.interface._base import NoFEM
|
|
3
3
|
from pyfemtet.opt.interface._femtet import FemtetInterface
|
|
4
4
|
from pyfemtet.opt.interface._femtet_with_sldworks import FemtetWithSolidworksInterface
|
pyfemtet/opt/interface/_base.py
CHANGED
|
@@ -5,11 +5,9 @@ from abc import ABC, abstractmethod
|
|
|
5
5
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
from pyfemtet.logger import get_logger
|
|
10
|
-
logger = get_logger('FEM')
|
|
11
|
-
logger.setLevel(logging.INFO)
|
|
8
|
+
from pyfemtet.logger import get_module_logger
|
|
12
9
|
|
|
10
|
+
logger = get_module_logger('opt.interface', __name__)
|
|
13
11
|
|
|
14
12
|
here, me = os.path.split(__file__)
|
|
15
13
|
|