Skip to content
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

Add Python API support #249

Open
wants to merge 148 commits into
base: master
Choose a base branch
from
Open

Add Python API support #249

wants to merge 148 commits into from

Conversation

cassava
Copy link
Contributor

@cassava cassava commented Jul 15, 2024

No description provided.

cassava and others added 30 commits April 22, 2024 13:03
This allows you to deploy a configuration to a directory:

    cloe-launch -v deploy -P engine/tests/conanfile_with_server.py /usr/local

This deployment should work without any further setup required.

An uninstaller is created at ~/.cache/cloe/launcher/UUID/uinstall.sh
where UUID is unique and determined from the configuration.
Readability and consistency are more important than performance here.
BREAKING CHANGE: This fundamentally changes how cloe-launch
parses arguments. They now have the form:

    cloe-launch [OPTS] COMMAND [CMD_OPTS] CONANFILE [CONAN_INSTALL_ARGS] [-- ARGS]

For commands such as `shell` and `exec` it's now necessary to use `--`
to pass arguments to them. It is also no longer possible to provide
options to the cloe-launch command after specifying the conanfile.
These now go to conan.
And make commands.options a protected module.
This should result in more reliable builds by default.
This option lets you prevent Python configuration files from
being loaded from CLOE_PLUGIN_PATH.
An empty entry in LD_LIBRARY_PATH is interpreted as the current
working directory. Conan sets LD_LIBRARY_PATH in such a way that
it inserts an empty entry, inadvertently.
CzBalti and others added 27 commits April 22, 2024 13:03
Up until now, we had one big cloe table that we patched
from several different places. This is not very maintainable
as the library grows and so another approach was needed.
Hopefully, this is the last large set of breaking changes.

- Tests can make use of expect_OP and assert_OP methods
  to provide better report generation.

  For example: z:expect_gt(left, right) will actually
  provide useful messages in the report, especially when
  something isn't as expected.

- Tests can use `expect_OP` methods to make assertions
  without terminating the test when they fail.

- At the end of cloe.schedule_test, it will automatically terminate
  the simulation with the appropriate result, depending on whether
  any expect / assert failed or not.

  If multiple tests were scheduled, the last one terminates the
  simulation.

  The results are written to the report.

  To disable this, set terminate = false in the schedule_test:

      cloe.schedule_test {
        id = "test",
        on = "start",
        run = function() end,
        terminate = false,
      }

BREAKING CHANGES:
- The Lua cloe library has been split into the pure Lua library,
  cloe, and the pure C++ library, cloe-engine.

- The engine now exports Lua state and functions to the cloe-engine Lua
  library, which is not loaded into the global namespace anymore.

  To access them, use:
  - `require("cloe-engine")`
  - `require("cloe-engine.fs")`
  - `require("cloe-engine.types")`

  These should not be used directly by users, instead functions
  and mechanisms in cloe should be used.

- The `cloe` global is no longer automatically set in the global
  namespace anymore:

  - This allows configuration of libraries before they are
    required by cloe.
  - The cloe library pulls in most of the cloe-engine Lua library.

- The files in the `cloe` library have reorganized.
  Require statements may need to be rewritten, if anything other
  than cloe was required.

- Signals table and requires is not directly accessible, instead
  you should use the functions provided:

      cloe.require_signals(table) => table
      cloe.require_signals_enum(table) => table
      cloe.signals() => table
      cloe.signal(string) => any

  For example, before and after:

      cloe.require_signals = {...}  ->  cloe.require_signals({ ... })
      cloe.signals["string"]        ->  cloe.signal("string")

  or alternatively, thanks to Lua syntax goodness:

      cloe.require_signals = {...}  ->  cloe.require_signals { ... }
      cloe.signals["string"]        ->  cloe.signal "string"

- The TestFixture class replaces the table previously used for
  the same purpose.

  - The methods need to be called with a colon, since this automatically
    passes the self to the function (which is needed):

        z.printf()         ->  z:printf()
        z.wait_duration()  ->  z:wait_duration()
        ...

  - `z:expect()` can be used to assert without terminating the
    simulation.

- Typecheck is used to replace `cloe.validate` for most function
  argument validation, as this provides much better error messages.

  If you have used cloe.validate, you need to use the new format
  or use `require("cloe.luax").validate` instead.

- Functions previously exported directly to the cloe table that
  were utility functions are now delegated to a separate namespace,
  in order to keep everything in cloe related.

  Thus, the `cloe.utils` has been renamed `cloe.luax`, since they
  are Lua extensions. They may be replaced in the future with a
  larger set of libraries, but for now they will stay.

- The table `cloe.report` has been moved to `cloe.system` and is
  no longer automatically included in cloe. You need to require it:

      local sys = require("cloe.system")

- The function `cloe.system` has been moved to the `system` table
  and renamed to `exec`. See previous point.
This could also easily be added for normal run, but it
seems like this is a good compromise between clarity and easy-of-use.
(The auto-require feature will feel like magic to users.)
BREAKING CHANGES:

- xdg_ functions take and return std::filesystem::path
  instead of boost::filesystem::path.

- Command takes a std::filesystem::path
  instead of boost::filesystem::path.

For the most part, all you need to do is change the namespace
to migrate.
And make it work when current_script_dir is not known.
BREAKING CHANGE:
- Do not write signals_autocompletion.json by default anymore.
Highlights:

- Add LogLevel enum type for use with cloe.log.
- Add cloe.events table/module with all default events and some custom ones.
- Add cloe.actions table/module with all default actions.
- Use tableshape to validate table types.
- Add Stack type definitions to cloe-engine.
- Improve documentation of many functions and methods.
New:
- Add `cloe-meta` package to replace previous role of `cloe`.

- Add `cloe-plugins-core` package recipe (but do not build).

- Add editable builds to GitHub workflow `build-cloe` matrix.

Changed:
- Package `cloe` provides all Cloe packages compiled in one go.
  This is a boon to development, as we make `cloe` editable and
  only have to work with a single package.
  It also massively speeds up compilation:
  - Conan and CMake configuration is only performed once.
  - All cores can now be utilized much more effectively during the build
    process.

- Do not aggressively lint everything
  The developer can do this themselves by setting a cmake define:
  https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html

- Move all individual tests into single project tests
  Still support multiple profiles, but this makes it easier
  to support the cloe super-build and should also make it
  easier to develop and maintain tests.

- Renamed top-level Make targets:
  - `status` is now `status-all`
  - `export` is now `export-all`
  - `deploy` is now `deploy-all`
  - `clean` is now `clean-all`
  - `purge` is now `purge-all`

- The following top-level Make targets just refer to `cloe` super-build package:
  - `package`
  - `smoketest`
  - `smoketest-deps`
  - `status`
  - `export`

Fixed:
- Plugin Conan configurations do not export correct library path.

Removed:
- Work-In-Progress Lua files.
@cassava cassava added this to the 0.26.0 milestone Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants