config.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. from taipy.common.config import Config, Frequency
  12. from .algorithms import evaluate, forecast
  13. model_cfg = Config.configure_data_node("model", path="my_model.p", storage_type="pickle")
  14. day_cfg = Config.configure_data_node(id="day")
  15. forecasts_cfg = Config.configure_data_node(id="forecasts")
  16. forecast_task_cfg = Config.configure_task(
  17. id="forecast_task",
  18. input=[model_cfg, day_cfg],
  19. function=forecast,
  20. output=forecasts_cfg,
  21. )
  22. historical_temperature_cfg = Config.configure_data_node(
  23. "historical_temperature",
  24. storage_type="csv",
  25. path="historical_temperature.csv",
  26. has_header=True,
  27. )
  28. evaluation_cfg = Config.configure_data_node("evaluation")
  29. evaluate_task_cfg = Config.configure_task(
  30. "evaluate_task",
  31. input=[historical_temperature_cfg, forecasts_cfg, day_cfg],
  32. function=evaluate,
  33. output=evaluation_cfg,
  34. )
  35. scenario_cfg = Config.configure_scenario("scenario", [forecast_task_cfg, evaluate_task_cfg], frequency=Frequency.DAILY)
  36. scenario_cfg.add_sequences({"sequence": [forecast_task_cfg, evaluate_task_cfg]})