From 5796b5b4b29d715a0a052e6f1729284f9c62c217 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 15:35:45 +0100 Subject: [PATCH 1/6] Fix: read the docs builds correctly for the webversion --- .readthedocs.yml | 8 +- README.md | 2 +- docs/Makefile | 2 + docs/source/conf.py | 86 +- pyproject.toml | 11 +- schema.json | 1984 ------------------------------------------- 6 files changed, 85 insertions(+), 2008 deletions(-) delete mode 100644 schema.json diff --git a/.readthedocs.yml b/.readthedocs.yml index 8ca14d3..3c6b9df 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -10,6 +10,9 @@ build: os: ubuntu-22.04 tools: python: "3.12" + jobs: + pre_build: + - python3 schema.py # You can also specify other tool versions: # nodejs: "19" # rust: "1.64" @@ -29,4 +32,7 @@ sphinx: # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - docs diff --git a/README.md b/README.md index 85e4444..5418075 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ dependencies for building the documentation. ``` console (base) $ conda create -n sphinx python=3.9 (base) $ conda activate sphinx -(sphinx) $ pip install sphinx sphinx-rtd-theme +(sphinx) $ pip install ".[docs]" ``` The documentation is built by executing the following command inside the folder diff --git a/docs/Makefile b/docs/Makefile index 26b9422..d26bf9e 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,4 +17,6 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile + python ../schema.py + mv schema.json ../ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/source/conf.py b/docs/source/conf.py index d51d909..f23e836 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,11 +12,12 @@ """ -import ast +from pydantic import BaseModel +from sphinx.ext.napoleon import _skip_member -with open("../../releso/__version__.py") as f: - version = ast.literal_eval(f.read().strip().split("=")[-1]) +from releso.__version__ import version +# sys.path.insert(0, str(releso_dir / "util")) # -- Project information ----------------------------------------------------- project = "ReLeSO" @@ -37,28 +38,23 @@ "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.napoleon", + "sphinx-jsonschema", # 'sphinxcontrib.autodoc_pydantic' ] autosummary_generate = True # Turn on sphinx.ext.autosummary # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -# autodoc_mock_imports = [ -# "pydantic", -# "tensorboard", -# "hjson", -# "gym", -# "stable_baselines3", -# "pandas", -# "gustaf", -# "numpy", -# "vedo", -# "matplotlib", -# "imageio", -# "torchvision", -# "torch", -# ] +autodoc_mock_imports = [ + "gymnasium", + "gustaf", + "vedo", + "matplotlib", + "imageio", + "torchvision", + "splinepy", +] # show type hints in doc body instead of signature -# autodoc_typehints = 'description' +# autodoc_typehints = "both" # get docstring from class level and init simultaneously # autoclass_content = 'instance' @@ -67,8 +63,8 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] -autodoc_pydantic_model_show_json = True -autodoc_pydantic_settings_show_json = False +# autodoc_pydantic_model_show_json = True +# autodoc_pydantic_settings_show_json = False # -- Options for HTML output ---------------------------------------------- @@ -83,3 +79,51 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] + + +# static variable needs only be initialized once +pydantic_functions = list(BaseModel.__dict__) + + +def skip(app, what, name, obj, would_skip, options): + """Check if member should be shown in the documentation. + + A little complication, is that if a `autodoc-skip-member` event is + registered if the `napoleon` extension is enabled, it will be called + instead of the default skip member function. (It is not additive) + So I am calling this function from this new skip function so that I do + not have to reimplement the same functionality. + + Additional members that are skipped are pydantic functions that are + inherited and functions that start with `check_` or `validate_`. These + functions are used as validators for the data in this package and should + normally not be called from user code. + + Args: + app (sphinx.application.Sphinx): Sphinx application. + what (str): Type of the object. + name (str): Name of the Object. + obj (Any): The object itself. + would_skip (bool): Decision of the object should be skipped from + previous checks. + options (Any): Options. + + Returns: + bool: Whether or not to skip the object. + """ + if would_skip := _skip_member(app, what, name, obj, would_skip, options): + return would_skip + if name in pydantic_functions: + return True + if name.startswith(("check_", "validate_")): + return True + # return would_skip + + +def setup(app): + """Method that is called from sphinx to load user code for the docs build. + + Args: + app (sphinx.application.Sphinx): Sphinx application. + """ + app.connect("autodoc-skip-member", skip) diff --git a/pyproject.toml b/pyproject.toml index 5d142f5..f83ceab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,8 @@ repository = "https://github.com/clemens-fricke/releso.git" [project.optional-dependencies] all = [ - "splinepy[all]" + "splinepy[all]", + "torchvision", ] test = [ "pytest", @@ -47,6 +48,14 @@ docs = [ "sphinx", "sphinx-rtd-theme", ] +dev = [ + "splinepy[all]", + "torchvision", + "pytest", + "pytest-cov", + "sphinx", + "sphinx-rtd-theme", +] [project.scripts] releso = "releso.__main__:entry" diff --git a/schema.json b/schema.json deleted file mode 100644 index be10b1f..0000000 --- a/schema.json +++ /dev/null @@ -1,1984 +0,0 @@ -{ - "title": "BaseParser", - "description": "Class parses the experiment definition and conducts the training.\n\nThis class can be used to initialize the ReLeSO Framework from the command\nline by reading in a json representation of the RL based Shape\nOptimization problem which is to be solved via Reinforcement Learning.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "verbosity": { - "$ref": "#/definitions/Verbosity" - }, - "agent": { - "title": "Agent", - "anyOf": [ - { - "$ref": "#/definitions/PPOAgent" - }, - { - "$ref": "#/definitions/DDPGAgent" - }, - { - "$ref": "#/definitions/SACAgent" - }, - { - "$ref": "#/definitions/PretrainedAgent" - }, - { - "$ref": "#/definitions/DQNAgent" - }, - { - "$ref": "#/definitions/A2CAgent" - } - ] - }, - "environment": { - "$ref": "#/definitions/Environment" - }, - "number_of_timesteps": { - "title": "Number Of Timesteps", - "minimum": 1, - "type": "integer" - }, - "number_of_episodes": { - "title": "Number Of Episodes", - "minimum": 1, - "type": "integer" - }, - "validation": { - "$ref": "#/definitions/Validation" - }, - "n_environments": { - "title": "N Environments", - "default": 1, - "minimum": 1, - "type": "integer" - }, - "normalize_training_values": { - "title": "Normalize Training Values", - "default": false, - "type": "boolean" - }, - "multi_env_sequential": { - "title": "Multi Env Sequential", - "default": false, - "type": "boolean" - } - }, - "required": [ - "save_location", - "agent", - "environment", - "number_of_timesteps" - ], - "additionalProperties": false, - "definitions": { - "Verbosity": { - "title": "Verbosity", - "description": "Verbosity class.\n\nDefines the settings for the different loggers used in the current\nexperiment. This class is the only class which is copied to all\nchildren. (this happens outside of the the standard channels and will\nhopefully not break with multiprocessing)\n\nPlease note, the parser logger only ever can have the following name\n``ReLeSO_parser``", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "parser": { - "title": "Parser", - "default": "INFO", - "enum": [ - "ERROR", - "WARNING", - "DEBUG", - "INFO" - ], - "type": "string" - }, - "environment": { - "title": "Environment", - "default": "INFO", - "enum": [ - "ERROR", - "WARNING", - "DEBUG", - "INFO" - ], - "type": "string" - }, - "logfile_location": { - "title": "Logfile Location", - "default": "logging/", - "type": "string" - }, - "console_logging": { - "title": "Console Logging", - "default": false, - "type": "boolean" - }, - "base_logger_name": { - "title": "Base Logger Name", - "default": "ReLeSO", - "type": "string" - }, - "environment_extension": { - "title": "Environment Extension", - "default": "environment", - "type": "string" - } - }, - "required": [ - "save_location" - ], - "additionalProperties": false - }, - "PPOAgent": { - "title": "PPOAgent", - "description": "PPO agent definition.\n\nPPO definition for the stable_baselines3 implementation for this algorithm.\nVariable comments are taken from the stable_baselines3 documentation.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "policy": { - "title": "Policy", - "enum": [ - "MlpPolicy", - "CnnPolicy", - "MultiInputPolicy" - ], - "type": "string" - }, - "use_custom_feature_extractor": { - "title": "Use Custom Feature Extractor", - "enum": [ - "resnet18", - "mobilenet_v2" - ], - "type": "string" - }, - "cfe_without_linear": { - "title": "Cfe Without Linear", - "default": false, - "type": "boolean" - }, - "policy_kwargs": { - "title": "Policy Kwargs", - "type": "object" - }, - "type": { - "title": "Type", - "enum": [ - "PPO" - ], - "type": "string" - }, - "learning_rate": { - "title": "Learning Rate", - "default": 0.0003, - "type": "number" - }, - "n_steps": { - "title": "N Steps", - "default": 2048, - "type": "integer" - }, - "batch_size": { - "title": "Batch Size", - "default": 64, - "type": "integer" - }, - "n_epochs": { - "title": "N Epochs", - "default": 10, - "type": "integer" - }, - "gamma": { - "title": "Gamma", - "default": 0.99, - "type": "number" - }, - "gae_lambda": { - "title": "Gae Lambda", - "default": 0.95, - "type": "number" - }, - "clip_range": { - "title": "Clip Range", - "default": 0.2, - "type": "number" - }, - "ent_coef": { - "title": "Ent Coef", - "default": 0.0, - "type": "number" - }, - "vf_coef": { - "title": "Vf Coef", - "default": 0.5, - "type": "number" - }, - "seed": { - "title": "Seed", - "type": "integer" - }, - "device": { - "title": "Device", - "default": "auto", - "type": "string" - } - }, - "required": [ - "save_location", - "policy", - "type" - ], - "additionalProperties": false - }, - "DDPGAgent": { - "title": "DDPGAgent", - "description": "DDPG agent definition.\n\nDDPG definition for the stable_baselines3 implementation for this\nalgorithm. Variable comments are taken from the stable_baselines3\ndocumentation.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "policy": { - "title": "Policy", - "enum": [ - "MlpPolicy", - "CnnPolicy", - "MultiInputPolicy" - ], - "type": "string" - }, - "use_custom_feature_extractor": { - "title": "Use Custom Feature Extractor", - "enum": [ - "resnet18", - "mobilenet_v2" - ], - "type": "string" - }, - "cfe_without_linear": { - "title": "Cfe Without Linear", - "default": false, - "type": "boolean" - }, - "policy_kwargs": { - "title": "Policy Kwargs", - "type": "object" - }, - "type": { - "title": "Type", - "enum": [ - "DDPG" - ], - "type": "string" - }, - "learning_rate": { - "title": "Learning Rate", - "default": 0.001, - "type": "number" - }, - "buffer_size": { - "title": "Buffer Size", - "default": 100000, - "type": "integer" - }, - "learning_starts": { - "title": "Learning Starts", - "default": 100, - "type": "integer" - }, - "batch_size": { - "title": "Batch Size", - "default": 64, - "type": "integer" - }, - "tau": { - "title": "Tau", - "default": 0.005, - "type": "number" - }, - "gamma": { - "title": "Gamma", - "default": 0.99, - "type": "number" - }, - "optimize_memory_usage": { - "title": "Optimize Memory Usage", - "default": false, - "type": "boolean" - }, - "seed": { - "title": "Seed", - "type": "integer" - }, - "device": { - "title": "Device", - "default": "auto", - "type": "string" - } - }, - "required": [ - "save_location", - "policy", - "type" - ], - "additionalProperties": false - }, - "SACAgent": { - "title": "SACAgent", - "description": "SAC Agent definition.\n\nSAC definition for the stable_baselines3 implementation for this algorithm.\nVariable comments are taken from the stable_baselines3 documentation.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "policy": { - "title": "Policy", - "enum": [ - "MlpPolicy", - "CnnPolicy", - "MultiInputPolicy" - ], - "type": "string" - }, - "use_custom_feature_extractor": { - "title": "Use Custom Feature Extractor", - "enum": [ - "resnet18", - "mobilenet_v2" - ], - "type": "string" - }, - "cfe_without_linear": { - "title": "Cfe Without Linear", - "default": false, - "type": "boolean" - }, - "policy_kwargs": { - "title": "Policy Kwargs", - "type": "object" - }, - "type": { - "title": "Type", - "enum": [ - "SAC" - ], - "type": "string" - }, - "learning_rate": { - "title": "Learning Rate", - "default": 0.001, - "type": "number" - }, - "buffer_size": { - "title": "Buffer Size", - "default": 1000000, - "type": "integer" - }, - "learning_starts": { - "title": "Learning Starts", - "default": 100, - "type": "integer" - }, - "batch_size": { - "title": "Batch Size", - "default": 64, - "type": "integer" - }, - "tau": { - "title": "Tau", - "default": 0.005, - "type": "number" - }, - "gamma": { - "title": "Gamma", - "default": 0.99, - "type": "number" - }, - "optimize_memory_usage": { - "title": "Optimize Memory Usage", - "default": false, - "type": "boolean" - }, - "ent_coef": { - "title": "Ent Coef", - "default": "auto", - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "target_update_interval": { - "title": "Target Update Interval", - "default": 1, - "type": "integer" - }, - "target_entropy": { - "title": "Target Entropy", - "default": "auto", - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "use_sde": { - "title": "Use Sde", - "default": false, - "type": "boolean" - }, - "sde_sample_freq": { - "title": "Sde Sample Freq", - "default": -1, - "type": "integer" - }, - "use_sde_at_warmup": { - "title": "Use Sde At Warmup", - "default": false, - "type": "boolean" - }, - "seed": { - "title": "Seed", - "type": "integer" - }, - "device": { - "title": "Device", - "default": "auto", - "type": "string" - } - }, - "required": [ - "save_location", - "policy", - "type" - ], - "additionalProperties": false - }, - "PretrainedAgent": { - "title": "PretrainedAgent", - "description": "Pretrained agent definition.\n\nThis class can be used to load pretrained agents, instead of using\nuntrained agents. Can also be used to only validate this agent without\ntraining it further. Please see validation section for this use-case.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "type": { - "title": "Type", - "enum": [ - "PPO", - "SAC", - "DDPG", - "A2C", - "DQN" - ], - "type": "string" - }, - "path": { - "title": "Path", - "anyOf": [ - { - "type": "string", - "format": "file-path" - }, - { - "type": "string", - "format": "path" - } - ] - }, - "tesorboard_run_directory": { - "title": "Tesorboard Run Directory", - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "format": "path" - } - ] - } - }, - "required": [ - "save_location", - "type", - "path" - ], - "additionalProperties": false - }, - "DQNAgent": { - "title": "DQNAgent", - "description": "DQN Agent definition.\n\nDQN definition for the stable_baselines3 implementation for this algorithm.\nVariable comments are taken from the stable_baselines3 documentation.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "policy": { - "title": "Policy", - "enum": [ - "MlpPolicy", - "CnnPolicy", - "MultiInputPolicy" - ], - "type": "string" - }, - "use_custom_feature_extractor": { - "title": "Use Custom Feature Extractor", - "enum": [ - "resnet18", - "mobilenet_v2" - ], - "type": "string" - }, - "cfe_without_linear": { - "title": "Cfe Without Linear", - "default": false, - "type": "boolean" - }, - "policy_kwargs": { - "title": "Policy Kwargs", - "type": "object" - }, - "type": { - "title": "Type", - "enum": [ - "DQN" - ], - "type": "string" - }, - "learning_rate": { - "title": "Learning Rate", - "default": 0.0001, - "type": "number" - }, - "buffer_size": { - "title": "Buffer Size", - "default": 1000000, - "type": "integer" - }, - "learning_starts": { - "title": "Learning Starts", - "default": 256, - "type": "integer" - }, - "batch_size": { - "title": "Batch Size", - "default": 32, - "type": "integer" - }, - "tau": { - "title": "Tau", - "default": 1.0, - "type": "number" - }, - "gamma": { - "title": "Gamma", - "default": 0.99, - "type": "number" - }, - "train_freq": { - "title": "Train Freq", - "default": 4, - "type": "integer" - }, - "gradient_steps": { - "title": "Gradient Steps", - "default": 1, - "type": "integer" - }, - "optimize_memory_usage": { - "title": "Optimize Memory Usage", - "default": false, - "type": "boolean" - }, - "target_update_interval": { - "title": "Target Update Interval", - "default": 256, - "type": "integer" - }, - "exploration_fraction": { - "title": "Exploration Fraction", - "default": 0.1, - "type": "number" - }, - "exploration_initial_eps": { - "title": "Exploration Initial Eps", - "default": 1.0, - "type": "number" - }, - "exploration_final_eps": { - "title": "Exploration Final Eps", - "default": 0.05, - "type": "number" - }, - "max_grad_norm": { - "title": "Max Grad Norm", - "default": 10, - "type": "number" - }, - "seed": { - "title": "Seed", - "type": "integer" - }, - "device": { - "title": "Device", - "default": "auto", - "type": "string" - } - }, - "required": [ - "save_location", - "policy", - "type" - ], - "additionalProperties": false - }, - "A2CAgent": { - "title": "A2CAgent", - "description": "A2c agent definition.\n\nA2C definition for the stable_baselines3 implementation for this algorithm.\nVariable comments are taken from the stable_baselines3 documentation.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "tensorboard_log": { - "title": "Tensorboard Log", - "type": "string" - }, - "policy": { - "title": "Policy", - "enum": [ - "MlpPolicy", - "CnnPolicy", - "MultiInputPolicy" - ], - "type": "string" - }, - "use_custom_feature_extractor": { - "title": "Use Custom Feature Extractor", - "enum": [ - "resnet18", - "mobilenet_v2" - ], - "type": "string" - }, - "cfe_without_linear": { - "title": "Cfe Without Linear", - "default": false, - "type": "boolean" - }, - "policy_kwargs": { - "title": "Policy Kwargs", - "type": "object" - }, - "type": { - "title": "Type", - "enum": [ - "A2C" - ], - "type": "string" - }, - "learning_rate": { - "title": "Learning Rate", - "default": 0.0007, - "type": "number" - }, - "n_steps": { - "title": "N Steps", - "default": 5, - "type": "integer" - }, - "gamma": { - "title": "Gamma", - "default": 0.99, - "type": "number" - }, - "gae_lambda": { - "title": "Gae Lambda", - "default": 1.0, - "type": "number" - }, - "ent_coef": { - "title": "Ent Coef", - "default": 0.0, - "type": "number" - }, - "vf_coef": { - "title": "Vf Coef", - "default": 0.5, - "type": "number" - }, - "seed": { - "title": "Seed", - "type": "integer" - }, - "device": { - "title": "Device", - "default": "auto", - "type": "string" - }, - "max_grad_norm": { - "title": "Max Grad Norm", - "default": 0.5, - "type": "number" - }, - "rms_prop_eps": { - "title": "Rms Prop Eps", - "default": 1e-05, - "type": "number" - }, - "use_rms_prop": { - "title": "Use Rms Prop", - "default": true, - "type": "boolean" - }, - "use_sde": { - "title": "Use Sde", - "default": false, - "type": "boolean" - }, - "sde_sample_freq": { - "title": "Sde Sample Freq", - "default": -1, - "type": "integer" - }, - "normalize_advantage": { - "title": "Normalize Advantage", - "default": false, - "type": "boolean" - } - }, - "required": [ - "save_location", - "policy", - "type" - ], - "additionalProperties": false - }, - "MultiProcessing": { - "title": "MultiProcessing", - "description": "Define multiprocessing capability of environment.\n\nDefines if the Problem should use Multiprocessing and with how many\ncores the solver can work. Does not force Multiprocessing for example\nif the solver does not support it.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "number_of_cores": { - "title": "Number Of Cores", - "default": 1, - "minimum": 1, - "type": "integer" - } - }, - "required": [ - "save_location" - ], - "additionalProperties": false - }, - "VariableLocation": { - "title": "VariableLocation", - "description": "Variable location class.\n\nObject of this class defines the position and movement possibilities for a\nsingle dimensions of a single control point of the geometry.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "current_position": { - "title": "Current Position", - "type": "number" - }, - "min_value": { - "title": "Min Value", - "type": "number" - }, - "max_value": { - "title": "Max Value", - "type": "number" - }, - "n_steps": { - "title": "N Steps", - "default": 10, - "minimum": 1, - "type": "integer" - }, - "step": { - "title": "Step", - "type": "number" - } - }, - "required": [ - "save_location", - "current_position" - ], - "additionalProperties": false - }, - "ShapeDefinition": { - "title": "ShapeDefinition", - "description": "Base of shape parameterization, also represents a simple point cloud.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "control_points": { - "title": "Control Points", - "type": "array", - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/VariableLocation" - } - } - } - }, - "required": [ - "save_location", - "control_points" - ], - "additionalProperties": false - }, - "SplineSpaceDimension": { - "title": "SplineSpaceDimension", - "description": "Defines a single spline space dimension of the current spline.\n\nThe dimension is a dimension of the parametric spline dimension.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "number_of_points": { - "title": "Number Of Points", - "minimum": 1, - "type": "integer" - }, - "degree": { - "title": "Degree", - "minimum": 1, - "type": "integer" - }, - "knot_vector": { - "title": "Knot Vector", - "type": "array", - "items": { - "type": "number" - } - } - }, - "required": [ - "save_location", - "name", - "number_of_points", - "degree" - ], - "additionalProperties": false - }, - "BSplineDefinition": { - "title": "BSplineDefinition", - "description": "Definition of the BSpline implementation of the ReLeSO Toolbox.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "control_points": { - "title": "Control Points", - "type": "array", - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/VariableLocation" - } - } - }, - "space_dimensions": { - "title": "Space Dimensions", - "type": "array", - "items": { - "$ref": "#/definitions/SplineSpaceDimension" - } - } - }, - "required": [ - "save_location", - "space_dimensions" - ], - "additionalProperties": false - }, - "NURBSDefinition": { - "title": "NURBSDefinition", - "description": "Definition of a NURBS spline.\n\nDefinition of the NURBS implementation of the ReLeSO Toolbox, in\ncomparison to the B-Spline implementation only an additional weights\nvector is added.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "control_points": { - "title": "Control Points", - "type": "array", - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/VariableLocation" - } - } - }, - "space_dimensions": { - "title": "Space Dimensions", - "type": "array", - "items": { - "$ref": "#/definitions/SplineSpaceDimension" - } - }, - "weights": { - "title": "Weights", - "type": "array", - "items": { - "anyOf": [ - { - "type": "number" - }, - { - "$ref": "#/definitions/VariableLocation" - } - ] - } - } - }, - "required": [ - "save_location", - "space_dimensions", - "weights" - ], - "additionalProperties": false - }, - "Geometry": { - "title": "Geometry", - "description": "Definition of the Geometry.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "shape_definition": { - "title": "Shape Definition", - "anyOf": [ - { - "$ref": "#/definitions/ShapeDefinition" - }, - { - "$ref": "#/definitions/BSplineDefinition" - }, - { - "$ref": "#/definitions/NURBSDefinition" - } - ] - }, - "action_based_observation": { - "title": "Action Based Observation", - "default": true, - "type": "boolean" - }, - "discrete_actions": { - "title": "Discrete Actions", - "default": true, - "type": "boolean" - }, - "reset_with_random_action_values": { - "title": "Reset With Random Action Values", - "default": false, - "type": "boolean" - } - }, - "required": [ - "save_location", - "shape_definition" - ], - "additionalProperties": false - }, - "MeshExporter": { - "title": "MeshExporter", - "description": "Class which defines in which format and where the mesh is exported.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "format": { - "title": "Format", - "default": "mixd", - "enum": [ - "mixd" - ], - "type": "string" - }, - "export_path": { - "title": "Export Path", - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "format": "path" - } - ] - } - }, - "required": [ - "save_location", - "export_path" - ], - "additionalProperties": false - }, - "MeshIOMesh": { - "title": "MeshIOMesh", - "description": "Provides an interface to load meshio meshes.\n\nSince gustaf currently only really supports .msh files, this also only\nsupports files with this ending. If and when gustaf implements support\nfor additional files types already supported by meshio. This will be\nupdated.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "path": { - "title": "Path", - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "format": "path" - } - ] - }, - "export": { - "$ref": "#/definitions/MeshExporter" - }, - "dimensions": { - "title": "Dimensions", - "minimum": 1, - "type": "integer" - } - }, - "required": [ - "save_location", - "dimensions" - ], - "additionalProperties": false - }, - "MixdMesh": { - "title": "MixdMesh", - "description": "Class used to read in the correct mixd mesh file and load it.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "path": { - "title": "Path", - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "format": "path" - } - ] - }, - "export": { - "$ref": "#/definitions/MeshExporter" - }, - "dimensions": { - "title": "Dimensions", - "minimum": 1, - "type": "integer" - }, - "mxyz_path": { - "title": "Mxyz Path", - "description": "Please use either the path variable xor the mxyz variable, since if used both the used mxyz path might not be the one you think.", - "format": "file-path", - "type": "string" - }, - "mien_path": { - "title": "Mien Path", - "description": "Please use either the path variable xor the mien variable, since if used both the used mien path might not be the one you think.", - "format": "file-path", - "type": "string" - }, - "hypercube": { - "title": "Hypercube", - "description": "If True Mesh is made of hypercubes. If False Mesh is made of simplexes (triangles).", - "default": true, - "type": "boolean" - } - }, - "required": [ - "save_location", - "dimensions" - ], - "additionalProperties": false - }, - "FFDGeometry": { - "title": "FFDGeometry", - "description": "FFD based variable shape.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "shape_definition": { - "title": "Shape Definition", - "anyOf": [ - { - "$ref": "#/definitions/ShapeDefinition" - }, - { - "$ref": "#/definitions/BSplineDefinition" - }, - { - "$ref": "#/definitions/NURBSDefinition" - } - ] - }, - "action_based_observation": { - "title": "Action Based Observation", - "default": true, - "type": "boolean" - }, - "discrete_actions": { - "title": "Discrete Actions", - "default": true, - "type": "boolean" - }, - "reset_with_random_action_values": { - "title": "Reset With Random Action Values", - "default": false, - "type": "boolean" - }, - "mesh": { - "title": "Mesh", - "anyOf": [ - { - "$ref": "#/definitions/MeshIOMesh" - }, - { - "$ref": "#/definitions/MixdMesh" - } - ] - }, - "export_mesh": { - "$ref": "#/definitions/MeshExporter" - } - }, - "required": [ - "save_location", - "shape_definition", - "mesh" - ], - "additionalProperties": false - }, - "ObservationDefinition": { - "title": "ObservationDefinition", - "description": "Definition of an Observation.\n\nDefinition of a single Observations by providing the name of the\nvalue and the range in which the value is limited to.\n\nThe range is necessary due to normalization of the input of the agent\nnetworks.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "value_min": { - "title": "Value Min", - "type": "number" - }, - "value_max": { - "title": "Value Max", - "type": "number" - } - }, - "required": [ - "save_location", - "name", - "value_min", - "value_max" - ], - "additionalProperties": false - }, - "ObservationDefinitionMulti": { - "title": "ObservationDefinitionMulti", - "description": "Define a multidimensional Observations space.\n\nDefinition of a single Observations by providing the name of the value\nand the range in which the value is limited to.\n\nThe range is necessary due to normalization of the input of the agent\nnetworks.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "value_min": { - "title": "Value Min", - "type": "number" - }, - "value_max": { - "title": "Value Max", - "type": "number" - }, - "observation_shape": { - "title": "Observation Shape", - "type": "array", - "items": { - "type": "integer" - } - }, - "value_type": { - "title": "Value Type", - "enum": [ - "float", - "CNN" - ], - "type": "string" - } - }, - "required": [ - "save_location", - "name", - "value_min", - "value_max", - "observation_shape", - "value_type" - ], - "additionalProperties": false - }, - "MultiProcessor": { - "title": "MultiProcessor", - "description": "Definition of the utilized multiprocessor. Default MPIEXEC.\n\nThe MultiProcessor gives access to command prefixes which can enable\nparallelization. Currently only tested for MPI.\n\nNote:\n The cluster uses PATH variables to correctly call mpi. IF you want to\n use MPI multiprocessing on the cluster please use\n :py:class:`ReLeSO.spor.MPIClusterMultiProcessor`.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "command": { - "title": "Command", - "default": "mpiexec -n", - "type": "string" - }, - "max_core_count": { - "title": "Max Core Count", - "minimum": 1, - "type": "integer" - }, - "always_use": { - "title": "Always Use", - "default": false, - "type": "boolean" - } - }, - "required": [ - "save_location", - "max_core_count" - ], - "additionalProperties": false - }, - "MPIClusterMultiProcessor": { - "title": "MPIClusterMultiProcessor", - "description": "Multi-processor extension for the cluster MPI call.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "command": { - "title": "Command", - "default": "$MPIEXEC", - "type": "string" - }, - "max_core_count": { - "title": "Max Core Count", - "minimum": 1, - "type": "integer" - }, - "always_use": { - "title": "Always Use", - "default": false, - "type": "boolean" - }, - "location": { - "title": "Location", - "enum": [ - "cluster" - ], - "type": "string" - }, - "mpi_flags_variable": { - "title": "Mpi Flags Variable", - "default": "$FLAGS_MPI_BATCH", - "type": "string" - } - }, - "required": [ - "save_location", - "max_core_count", - "location" - ], - "additionalProperties": false - }, - "SPORObjectCommandLine": { - "title": "SPORObjectCommandLine", - "description": "Base definition of a SPORCommandLineObject. Can be instantiated.\n\nBase class for all possible SPOR object classes which use the command\nline. This class is meant to add some default functionality, so that\nusers do not need to add them themselves. These are:\n\n1. access to the (MPI) Multi-processors via\n :py:class:`ReLeSO.spor.MultiProcessor`\n2. command line command\n3. additional flags\n4. working directory\n5. whether or not to use the\n :ref:`SPOR Communication Interface `", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "stop_after_error": { - "title": "Stop After Error", - "default": true, - "type": "boolean" - }, - "reward_on_error": { - "title": "Reward On Error", - "type": "number" - }, - "reward_on_completion": { - "title": "Reward On Completion", - "type": "number" - }, - "run_on_reset": { - "title": "Run On Reset", - "default": true, - "type": "boolean" - }, - "additional_observations": { - "title": "Additional Observations", - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - }, - { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - } - ] - } - } - ] - }, - "multi_processor": { - "title": "Multi Processor", - "anyOf": [ - { - "$ref": "#/definitions/MultiProcessor" - }, - { - "$ref": "#/definitions/MPIClusterMultiProcessor" - } - ] - }, - "use_communication_interface": { - "title": "Use Communication Interface", - "default": false, - "type": "boolean" - }, - "add_step_information": { - "title": "Add Step Information", - "default": false, - "type": "boolean" - }, - "working_directory": { - "title": "Working Directory", - "type": "string" - }, - "execution_command": { - "title": "Execution Command", - "type": "string" - }, - "command_options": { - "title": "Command Options", - "default": [], - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "save_location", - "name", - "reward_on_error", - "working_directory", - "execution_command" - ], - "additionalProperties": false - }, - "SPORObjectExternalPythonFunction": { - "title": "SPORObjectExternalPythonFunction", - "description": "Load a python function from an external file.\n\nThis class is meant to load a python function from an external file and\nexecute it. The function will be imported in to the package and run in the\n same python environment as the rest of the package is. If you want to call\n the function you can use the SPORCommandLineObject.\n\nThe function needs to be called main and needs to have the\nfollowing signature:\n args, logger, func_data\n\nWhere args are the SPOR COMM arguments, logger is a logger provided by\nthe SPORObject and, func_data is a persistent data variable which is not\ntouched by the SPORObject.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "stop_after_error": { - "title": "Stop After Error", - "default": true, - "type": "boolean" - }, - "reward_on_error": { - "title": "Reward On Error", - "type": "number" - }, - "reward_on_completion": { - "title": "Reward On Completion", - "type": "number" - }, - "run_on_reset": { - "title": "Run On Reset", - "default": true, - "type": "boolean" - }, - "additional_observations": { - "title": "Additional Observations", - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - }, - { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - } - ] - } - } - ] - }, - "multi_processor": { - "title": "Multi Processor", - "anyOf": [ - { - "$ref": "#/definitions/MultiProcessor" - }, - { - "$ref": "#/definitions/MPIClusterMultiProcessor" - } - ] - }, - "use_communication_interface": { - "title": "Use Communication Interface", - "default": false, - "type": "boolean" - }, - "add_step_information": { - "title": "Add Step Information", - "default": false, - "type": "boolean" - }, - "working_directory": { - "title": "Working Directory", - "type": "string" - }, - "python_file_path": { - "title": "Python File Path", - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "format": "path" - } - ] - } - }, - "required": [ - "save_location", - "name", - "reward_on_error", - "working_directory", - "python_file_path" - ], - "additionalProperties": false - }, - "SPORObjectInternalPythonFunction": { - "title": "SPORObjectInternalPythonFunction", - "description": "This class will load SPOR functions provided by this package.\n\nCurrently available functions are the following:\n\n - xns_cnn: This function will use the result of the xns solver and\n create an image of the solution. The image is created via contourf.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "stop_after_error": { - "title": "Stop After Error", - "default": true, - "type": "boolean" - }, - "reward_on_error": { - "title": "Reward On Error", - "type": "number" - }, - "reward_on_completion": { - "title": "Reward On Completion", - "type": "number" - }, - "run_on_reset": { - "title": "Run On Reset", - "default": true, - "type": "boolean" - }, - "additional_observations": { - "title": "Additional Observations", - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - }, - { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/ObservationDefinition" - }, - { - "$ref": "#/definitions/ObservationDefinitionMulti" - } - ] - } - } - ] - }, - "multi_processor": { - "title": "Multi Processor", - "anyOf": [ - { - "$ref": "#/definitions/MultiProcessor" - }, - { - "$ref": "#/definitions/MPIClusterMultiProcessor" - } - ] - }, - "use_communication_interface": { - "title": "Use Communication Interface", - "default": false, - "type": "boolean" - }, - "add_step_information": { - "title": "Add Step Information", - "default": false, - "type": "boolean" - }, - "working_directory": { - "title": "Working Directory", - "type": "string" - }, - "function_name": { - "title": "Function Name", - "enum": [ - "xns_cnn" - ], - "type": "string" - } - }, - "required": [ - "save_location", - "name", - "reward_on_error", - "working_directory", - "function_name" - ], - "additionalProperties": false - }, - "SPORList": { - "title": "SPORList", - "description": "The SPORList defines the custom defined steps.\n\nIn the current version these steps take place after the FFD is\ndone. These can include the fluid solver, post-processing steps,\nreward generation, additional logging, etc. In a future version the FFD\nmight be incorporated into a SPOR step to stream line the internal\nfunctionality.\n\nIf a step sends a stop signal all consecutive steps will be ignored and the\nEach step can generate observations, rewards and info for the current\nepisode step. These are aggregated as follows.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "steps": { - "title": "Steps", - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/SPORObjectCommandLine" - }, - { - "$ref": "#/definitions/SPORObjectExternalPythonFunction" - }, - { - "$ref": "#/definitions/SPORObjectInternalPythonFunction" - } - ] - } - }, - "reward_aggregation": { - "title": "Reward Aggregation", - "enum": [ - "sum", - "min", - "max", - "mean", - "absmax" - ], - "type": "string" - } - }, - "required": [ - "save_location", - "steps", - "reward_aggregation" - ], - "additionalProperties": false - }, - "Environment": { - "title": "Environment", - "description": "Parser class of which the environment is based.\n\nParser Environment object is created by pydantic during the parsing of the\njson object defining the RL based Shape optimization. Each object can\ncreate a gym environment that represents the given problem.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "multi_processing": { - "$ref": "#/definitions/MultiProcessing" - }, - "geometry": { - "title": "Geometry", - "anyOf": [ - { - "$ref": "#/definitions/Geometry" - }, - { - "$ref": "#/definitions/FFDGeometry" - } - ] - }, - "spor": { - "$ref": "#/definitions/SPORList" - }, - "max_timesteps_in_episode": { - "title": "Max Timesteps In Episode", - "minimum": 1, - "type": "integer" - }, - "end_episode_on_geometry_not_changed": { - "title": "End Episode On Geometry Not Changed", - "default": false, - "type": "boolean" - }, - "reward_on_geometry_not_changed": { - "title": "Reward On Geometry Not Changed", - "type": "number" - }, - "reward_on_episode_exceeds_max_timesteps": { - "title": "Reward On Episode Exceeds Max Timesteps", - "type": "number" - } - }, - "required": [ - "save_location", - "geometry", - "spor" - ], - "additionalProperties": false - }, - "Validation": { - "title": "Validation", - "description": "Parser class to define the validation to be performed during training.\n\nThis class is used for the configuration of how validation is to be\nperformed during training.", - "type": "object", - "properties": { - "save_location": { - "title": "Save Location", - "type": "string", - "format": "path" - }, - "logger_name": { - "title": "Logger Name", - "type": "string" - }, - "validation_freq": { - "title": "Validation Freq", - "minimum": 1, - "type": "integer" - }, - "validation_values": { - "title": "Validation Values", - "minItems": 1, - "type": "array", - "items": { - "type": "number" - } - }, - "save_best_agent": { - "title": "Save Best Agent", - "type": "boolean" - }, - "validate_on_training_end": { - "title": "Validate On Training End", - "type": "boolean" - }, - "max_timesteps_in_episode": { - "title": "Max Timesteps In Episode", - "minimum": 1, - "type": "integer" - }, - "end_episode_on_geometry_not_changed": { - "title": "End Episode On Geometry Not Changed", - "default": false, - "type": "boolean" - }, - "reward_on_geometry_not_changed": { - "title": "Reward On Geometry Not Changed", - "type": "number" - }, - "reward_on_episode_exceeds_max_timesteps": { - "title": "Reward On Episode Exceeds Max Timesteps", - "type": "number" - } - }, - "required": [ - "save_location", - "validation_values", - "save_best_agent", - "validate_on_training_end" - ], - "additionalProperties": false - } - } -} From 4b7a33e549178ebeaeba0921c40c2b1bb8e4a4e5 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 15:36:36 +0100 Subject: [PATCH 2/6] Ref: Renamed build workflow to be able to linkt to it easier --- .github/workflows/build_and_upload_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_upload_wheels.yml b/.github/workflows/build_and_upload_wheels.yml index 952f266..2b692db 100644 --- a/.github/workflows/build_and_upload_wheels.yml +++ b/.github/workflows/build_and_upload_wheels.yml @@ -1,4 +1,4 @@ -name: pypi upload +name: pypi_upload on: push: From 015d680d7aa85be7b610d90b6081267fa889a45b Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 15:37:35 +0100 Subject: [PATCH 3/6] Ref: Mostly reformatting --- releso/parser_environment.py | 2 +- releso/shape_parameterization.py | 4 ++-- releso/spline.py | 2 +- releso/spor.py | 9 ++------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/releso/parser_environment.py b/releso/parser_environment.py index 6161f44..1dbb2f5 100644 --- a/releso/parser_environment.py +++ b/releso/parser_environment.py @@ -516,7 +516,7 @@ def step(self, action: Any) -> Tuple[Any, float, bool, Dict[str, Any]]: if observations["geometry_observation"] is None: del observations["geometry_observation"] end = timer() - self.get_logger().debug(f"Step took {end-start} seconds.") + self.get_logger().debug(f"Step took {end - start} seconds.") return self.check_observations(observations), reward, done, False, info diff --git a/releso/shape_parameterization.py b/releso/shape_parameterization.py index 5846fcf..5c2912c 100644 --- a/releso/shape_parameterization.py +++ b/releso/shape_parameterization.py @@ -90,7 +90,7 @@ def set_variable_to_current_position_if_not_given( @validator("max_value", always=True) @classmethod - def max_value_is_greater_than_current_value( + def check_max_value_is_greater_than_current_value( cls, v, values, field ) -> float: """Validates that the max value is greater-equal to the current value. @@ -114,7 +114,7 @@ def max_value_is_greater_than_current_value( @validator("min_value", always=True) @classmethod - def min_value_is_smaller_than_current_value( + def check_min_value_is_smaller_than_current_value( cls, v, values, field ) -> float: """Validates that the min value is smaller-equal to the current value. diff --git a/releso/spline.py b/releso/spline.py index 65348ef..5d0a628 100644 --- a/releso/spline.py +++ b/releso/spline.py @@ -108,7 +108,7 @@ def validate_knot_vector( else: get_parser_logger().warning( f"The knot vector is shorter {n_knots} than the length " - f"given by the open format {starting_ending*2}. Knot " + f"given by the open format {starting_ending * 2}. Knot " "vector is created by adding the starting and ending " "parts. The knot vector might be to long." ) diff --git a/releso/spor.py b/releso/spor.py index 4d6f2dc..0bdf498 100644 --- a/releso/spor.py +++ b/releso/spor.py @@ -203,11 +203,6 @@ def validate_additional_observations( Validates the the additional observations variable. This is a pre validation function only used for back compatibility reasons. - See deprecation notice... - - Deprecated functionality: Setting the value of the additional variable - to an int value. This is an old option and is not supported anymore. - Please define additional variable with the classes given. Args: v (str): See pydantic @@ -1018,7 +1013,7 @@ def run( ) from err else: self._run_logger = set_up_logger( - f"spor_step_logger_{self.name.replace(' ','_')}", + f"spor_step_logger_{self.name.replace(' ', '_')}", pathlib.Path(self.save_location / "logging"), VerbosityLevel.INFO, console_logging=False, @@ -1428,6 +1423,6 @@ def run( step_information = (observations, reward, done, info) end = timer() self.get_logger().debug( - f"SPOR Step {step.name} took {end-start} seconds." + f"SPOR Step {step.name} took {end - start} seconds." ) return step_information From adb41c7ca6057fa8d4d7dbcd629587466555af51 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 15:38:18 +0100 Subject: [PATCH 4/6] Ref: Rework some of the documentation --- docs/source/feature_extractor.rst | 2 +- docs/source/image_based_observations.rst | 8 +++- docs/source/index.rst | 42 ++++++++++++++--- docs/source/installation.rst | 60 ++++++++++-------------- docs/source/json_schema.rst | 6 ++- 5 files changed, 72 insertions(+), 46 deletions(-) diff --git a/docs/source/feature_extractor.rst b/docs/source/feature_extractor.rst index 0ae0e9d..850d9c9 100644 --- a/docs/source/feature_extractor.rst +++ b/docs/source/feature_extractor.rst @@ -1,7 +1,7 @@ Feature Extractor ================= -This package has (Version>=1.1) the ability to use custom feature +This package has the ability to use custom feature extractors for the agent networks. When using a custom feature extractor the observations are first fed into the feature extractor and the result is then fed into the agent networks. Please see the `stable-baselines3 diff --git a/docs/source/image_based_observations.rst b/docs/source/image_based_observations.rst index a5687bf..4361ade 100644 --- a/docs/source/image_based_observations.rst +++ b/docs/source/image_based_observations.rst @@ -1,11 +1,15 @@ Image based Observations ======================== +.. Note:: This functionalty has been reworked and the documentation is not up to date. Please check the schema for the renamed/relocated options and functionality. + +.. Note:: The solver used in this example is not openly available. The functionality after creating the image should work with any solver. + The framework has now the ability to not only use the spline coordinates as the observations but it can also use image based observations. These use flow -field informations directly from the solver to create a false color image of +field information directly from the solver to create a false color image of the flow field. This means that this feature is currently only available in -conjuction with the **XNS** solver, from CATS RWTH Aachen. Other solver would +conjunction with the **XNS** solver, from CATS RWTH Aachen. Other solver would need to either do **one** of these options: #. export the results to the same location and in the same format diff --git a/docs/source/index.rst b/docs/source/index.rst index da7c217..6c560be 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,19 +3,42 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to ReLeSO's documentation! -================================== Reinforcement Learning based Shape Optimization (ReLeSO) ======================================================== +|Build Status| |Documentation Status| +|PyPI| |Python| |License| -**ReLeSO** stands for ``Reinforcement Learning based Shape Optimization`` and is a Python framework combining the spline base shape optimization approach with the reinforcement learning. +.. |Build Status| image:: https://img.shields.io/github/actions/workflow/status/clemens-fricke/releso/pypi_upload + :target: https://github.com/clemens-fricke/releso + :alt: PyPI - Version -This documentation holds just the usage information and possible configuration parameters of this framework but not the theory behind this approach. Please see the thesis "Python Framework for Reinforcement Learning based Shape Optimization" by Clemens Fricke. Please contact Clemens Fricke (clemens.david.fricke@tuwien.ac.at) or Daniel Wolff (wolff@cats.rwth-aachen.de) to access it. +.. |Documentation Status| image:: https://readthedocs.org/projects/releso/badge/?version=latest + :target: https://releso.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status -This framework is mainly build upon the Python packages ``pydantic`` and ``stable-baselines3``. +.. .. |codecov| image:: https://codecov.io/gh/clemensfricke/ReLeSO/branch/master/graph/badge.svg +.. :target: https://codecov.io/gh/clemensfricke/ReLeSO +.. :alt: Code Coverage + +.. |PyPI| image:: https://img.shields.io/pypi/v/releso + :target: https://pypi.org/project/releso/ + :alt: PyPI + +.. |Python| image:: https://img.shields.io/pypi/pyversions/releso + :target: https://pypi.org/project/releso/ + :alt: Python + +.. |License| image:: https://img.shields.io/pypi/l/releso + :target: https://github.com/clemens-fricke/releso/blob/main/LICENSE + :alt: PyPI - License + +**ReLeSO** stands for ``Reinforcement Learning based Shape Optimization`` and is a Python framework combining the spline base shape optimization approach with reinforcement learning. + +This documentation includes the usage information and possible configuration parameters of this framework. Please see the thesis "Python Framework for Reinforcement Learning based Shape Optimization" by Clemens Fricke. Please contact Clemens Fricke (clemens.david.fricke@tuwien.ac.at) or Daniel Wolff (wolff@cats.rwth-aachen.de) to access it. +We also released two papers with results obtained with this framework, that also go into the theory of the application of Shape Optimization with Reinforcement Learning. The first paper is a short proceedings about the basic concept of concept of ReLeSO for an introductory example to optimzation of extrusion dies [Wolff2023]_ and the second paper is a more detailed paper about the possible optimizations steps towards better learning [Fricke2023]_. In the last paper we compare different agents and the two type RL based Shape Optimization this Framework implements, incremental and direct optimization. + +This framework is mainly build upon the Python packages ``pydantic`` and ``stable-baselines3``. Especially the RL agents used are from the ``stable-baselines3`` package. So please refer to the documentation of these packages for further information about the agents and a deeper understanding of RL in general. The documentation given `there `_ is very good and easy to understand. -.. note:: - This project is still under development. For guidance on the installation process see :doc:`installation`. @@ -37,3 +60,8 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` + + +.. [Wolff2023] Wolff, D., Fricke, C., Kemmerling, M., & Elgeti, S. (2023). `Towards shape optimization of flow channels in profile extrusion dies using reinforcement learning `_. PAMM, 22(1), e202200009 + +.. [Fricke2023] Fricke, C., Wolff, D., Kemmerling, M., & Elgeti, S. (2023). `Investigation of reinforcement learning for shape optimization of 2D profile extrusion die geometries `_. Advances in Computational Science and Engineering, 1(1), 1-35. diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 1895eae..4050a3f 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -1,62 +1,54 @@ Installation ============ -This page covers the installation process of the framework and its prerequisites. - -Prerequisites -------------- -To use ReLeSO the following packages have to be installed: - - pydantic<2.0 - - stable-baselines3 - - tensorboard - - torchvision - - hjson - - gustaf - -The first two/three packages can be installed via pip and/or conda with the following command: - -**pip** (activation of the venv should be done beforehand) +The package is available via PyPI and can be installed via pip: .. code-block:: console - (.venv) $ pip install "pydantic<2.0" stable-baselines3 tensorboard hjson + (env) $ pip install releso -**conda** - -.. code-block:: console +This command will install the package with the minimal dependencies. - (base) $ conda create -n releso python=3.9 pydantic<2.0 tensorboard - (base) $ conda activate releso - (releso) $ conda install -c pytorch torchvision - (releso) $ pip install stable-baselines3 hjson +The following packages are optional and bring further capabilities to the framework: + - splinepy -> Spline based geometries + - gustaf -> If Free Form Deformations is used + - torchvision -> If Image based observations are used -The next step is to install the ``gustaf`` package which is a python interface for the c++ library SplineLib. -To install ``gustaf`` the following repository must be downloaded into an external folder and installed into the venv or conda environment as before. The installation process for the gustaf package is documented in the README file of the repository. +These can be automatically install via the following command: +.. code-block:: console -**Development** + (env) $ pip install "releso[all]" -To develop the framework further the sphinx package should also be installed with the currently used sphinx html theme ``sphinx_rtd_theme``. -The this can be done via: -.. code-block:: console +.. note:: + It is recommended to use a environment manager like conda to install the packages into an environment. - (releso) $ pip install sphinx sphinx_rtd_theme +Installation from source +------------------------ -Framework ---------- +Clone the `repository `_ from github. -After installing all prerequisites the framework itself can be installed by running the command below in the main repository folder +There are two modes that a package can be installed from source. **Non-development** +The package is basically installed like it would from PyPI. This can be done via: + .. code-block:: console (releso) $ pip install . **Development** +The development mode of *pip install* allows to change the source code and have the changed +directly reflected in the installed package. Meaning no recompliation before starting the +next script call is necessary (If you use an IPython kernel you will have to restart the kernel +to see the changes). This is done by adding the ``-e`` flag to the pip install command. +The development mode can be installed via: .. code-block:: console - (releso) $ pip install -e . + (releso) $ pip install -e ".[dev]" + +The def extension will install all optional dependencies as well as the development dependencies. diff --git a/docs/source/json_schema.rst b/docs/source/json_schema.rst index e179b3b..58bbd78 100644 --- a/docs/source/json_schema.rst +++ b/docs/source/json_schema.rst @@ -2,5 +2,7 @@ JSON SCHEMA ReLeSO =================== The input file must be written to comply to the following json-schema. -.. literalinclude:: ../../schema.json - :language: json +.. jsonschema:: ../../schema.json + :lift_definitions: + :auto_reference: + :auto_target: From bd508aa21ed3b2b77845501d19fe13a1b3ffff0d Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 18:27:46 +0100 Subject: [PATCH 5/6] Ref: Updated links to new organisation tataratat --- README.md | 20 +++++++++++--------- docs/source/index.rst | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5418075..7ed7363 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ -# Reinforcement Learning based Shape Optimization +# Reinforcement Learning based Shape Optimization (ReLeSO) -This repository holds a Library/Framework written by Clemens Fricke for +[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/tataratat/releso/pypi_upload)](https://github.com/tataratat/releso) +[![Read the docs](https://readthedocs.org/projects/releso/badge/?version=latest)](https://releso.readthedocs.io/en/latest/?badge=latest) +[![PyPI - Version](https://img.shields.io/pypi/v/releso)](https://pypi.org/project/releso/) +[![Python Versions](https://img.shields.io/pypi/pyversions/releso)](https://pypi.org/project/releso/) +[![PyPI - License](https://img.shields.io/pypi/l/releso)](https://github.com/tataratat/releso/blob/main/LICENSE) + +Releso is a Library/Framework for Reinforcement Learning based Shape Optimization. Please look into the Documentation for information on how it works. The instruction on how the documentation can be built is given below as well as the instruction on how the -package can be installed. It is currently not available from `pip`, this might -come in the future. +package can be installed. But it is also available to install via `pip install releso`. Documentation generation @@ -41,7 +46,7 @@ This section covers the installation process of the framework and its prerequisites. The first thing to note is that with version 0.1.0 the strict dependency on `splinepy` is not present anymore. But if the geometry is to be parameterized by a Spline and the method of Free Form -Deformation is to be used to deform a mesh, `splinepy` is +Deformation is to be used to deform a mesh, `splinepy` is still necessary. Prerequisites @@ -70,9 +75,6 @@ The packages can be installed via pip or conda with the following commands: (base) $ conda activate releso (releso) $ pip install stable-baselines3 hjson ``` -> The quotation marks are necessary for some command lines like `zsh`. But from -testing, `bash` is also ok if you use them even though they are not necessary. - If the spline-based shape optimization functionality is needed, the package ``splinepy`` is needed. Please visit @@ -104,5 +106,5 @@ running the command below in the main repository folder. **Development** ``` console -(releso) $ pip install -e . +(releso) $ pip install -e "dev." ``` diff --git a/docs/source/index.rst b/docs/source/index.rst index 6c560be..e64c415 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,8 +8,8 @@ Reinforcement Learning based Shape Optimization (ReLeSO) |Build Status| |Documentation Status| |PyPI| |Python| |License| -.. |Build Status| image:: https://img.shields.io/github/actions/workflow/status/clemens-fricke/releso/pypi_upload - :target: https://github.com/clemens-fricke/releso +.. |Build Status| image:: https://img.shields.io/github/actions/workflow/status/tataratat/releso/pypi_upload + :target: https://github.com/tataratat/releso :alt: PyPI - Version .. |Documentation Status| image:: https://readthedocs.org/projects/releso/badge/?version=latest @@ -29,7 +29,7 @@ Reinforcement Learning based Shape Optimization (ReLeSO) :alt: Python .. |License| image:: https://img.shields.io/pypi/l/releso - :target: https://github.com/clemens-fricke/releso/blob/main/LICENSE + :target: https://github.com/tataratat/releso/blob/main/LICENSE :alt: PyPI - License **ReLeSO** stands for ``Reinforcement Learning based Shape Optimization`` and is a Python framework combining the spline base shape optimization approach with reinforcement learning. From 8a4c6ade3f1b854a55d3a2ebcab5ca24f01b865e Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 23 Nov 2023 21:47:13 +0100 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Daniel Wolff <39346676+danielwolff1@users.noreply.github.com> --- README.md | 3 ++- docs/source/index.rst | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7ed7363..f39b83e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ Releso is a Library/Framework for Reinforcement Learning based Shape Optimization. Please look into the Documentation for information on how it works. The instruction on how the documentation can be built is given below as well as the instruction on how the -package can be installed. But it is also available to install via `pip install releso`. +package can be installed. +Alternatively, it can be installed from `pip` via `pip install releso`. Documentation generation diff --git a/docs/source/index.rst b/docs/source/index.rst index e64c415..56ac49a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -32,10 +32,12 @@ Reinforcement Learning based Shape Optimization (ReLeSO) :target: https://github.com/tataratat/releso/blob/main/LICENSE :alt: PyPI - License -**ReLeSO** stands for ``Reinforcement Learning based Shape Optimization`` and is a Python framework combining the spline base shape optimization approach with reinforcement learning. +**ReLeSO** stands for ``Reinforcement Learning based Shape Optimization`` and is a Python framework combining a spline-based shape optimization approach with reinforcement learning. + This documentation includes the usage information and possible configuration parameters of this framework. Please see the thesis "Python Framework for Reinforcement Learning based Shape Optimization" by Clemens Fricke. Please contact Clemens Fricke (clemens.david.fricke@tuwien.ac.at) or Daniel Wolff (wolff@cats.rwth-aachen.de) to access it. -We also released two papers with results obtained with this framework, that also go into the theory of the application of Shape Optimization with Reinforcement Learning. The first paper is a short proceedings about the basic concept of concept of ReLeSO for an introductory example to optimzation of extrusion dies [Wolff2023]_ and the second paper is a more detailed paper about the possible optimizations steps towards better learning [Fricke2023]_. In the last paper we compare different agents and the two type RL based Shape Optimization this Framework implements, incremental and direct optimization. +We also released two papers with results obtained with this framework, that also go into the theory of the application of Shape Optimization with Reinforcement Learning. The first paper is a short proceedings about the basic concept of concept of ReLeSO for an introductory example to optimzation of extrusion dies [Wolff2023]_ and the second paper is a more detailed paper about the possible optimization steps towards better learning [Fricke2023]_. In the last paper we compare different agents and the two types of RL-based shape optimization that this framework implements, namely incremental and direct optimization. + This framework is mainly build upon the Python packages ``pydantic`` and ``stable-baselines3``. Especially the RL agents used are from the ``stable-baselines3`` package. So please refer to the documentation of these packages for further information about the agents and a deeper understanding of RL in general. The documentation given `there `_ is very good and easy to understand.