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

Feat/migration tool #624

Merged
merged 36 commits into from
Aug 22, 2024
Merged

Feat/migration tool #624

merged 36 commits into from
Aug 22, 2024

Conversation

Pouyanpi
Copy link
Collaborator

This PR facilitates the migration from both Colang 1.0 and Colang 2.0-alpha to Colang 2.x. It introduces a migration script with the following key features and fixes:

  • A new command in the CLI for translating both Colang 1.0 and Colang 2.0-alpha to Colang 2.x.
  • Normalization of action names and addition of a registration check to ensure compatibility with the Colang 2.x ActionName convention.
  • Enabling of context updates in Colang 2.x.
  • Refactored Colang parsing and added a version detection heuristic.
  • Generation of a _rails.co file if rails are defined in the config.yml, and validation of the translation using the Colang 2.x parser.

This commit introduces a new migration script that helps in migrating colang (.co) files and config (.yaml/.yml) files from older versions to the latest version.
The script supports migration from "1.0" and"2.0-alpha" versions to the latest version.
The script also validates the migrated files to ensure they arecorrect.
The conversion functions convert_colang_2alpha_syntax and
convert_colang_1_syntax have been refactored to accept a list of lines
instead of a file path
Transforms the colang 1 syntax to colang 2
Add _rails.co file if the rails are defined in config.yml
Validates the translation using Colang 2.x parser

Fix indentation of globalize and avoid more than once migration
To make action names compatible with colang 2.x ActionName convention
It is already fixed in another PR
Allows use of name from action decorator after execute instead of function name
…or' default value to True and remove 'add_main'
This commit marks the
test as skipped. This test is currently not working as expected and
needs to be reviewed and fixed.
This commit refactors the variable names in the migration script for
better readability. The variable 'stripped_line' has
been renamed to 'line'.

The changes also include the addition of new syntax conversions like
'bot ...' to 'match UtteranceBotActionFinished()' and 'user ...' to
'match UtteranceUserActionFinished()'.
the regex used to extract the action name after "await" or "execute" has been updated. Now it correctly identifies the action name as the part before the first parenthesis.
This commit changes the behavior of the migration script. Instead of
removing the rails flows from the configuration file, it now comments
them out. This allows for easier rollback and preserves the original
file structure. The rails flows are written to a separate file named
_rails.co for reference. This approach is used as yaml.dump in PyYAML distorts the formating and key ordering.
@Pouyanpi Pouyanpi requested a review from drazvan July 11, 2024 13:45
This commit updates the syntax for regex and loop_id in the
migration.py file. The regex syntax is updated to include
parentheses around the regex pattern. The loop_id syntax is
updated to include quotes around the loop_id. Update the corresponding tests

add tests
This commit introduces several enhancements to the migration script.
1. It adds a new function '_set_colang_version' which sets the 'colang_version'
   in the given raw_config. If 'colang_version' already exists, it replaces it.
   If it doesn't exist, it inserts it at the first line.
2. It modifies the '_process_config_files' function to call the new
   '_set_colang_version' function, setting the colang version to 2.x.
3. It changes the '_comment_rails_flows_in_config' function to comment out the
   'rails:' line if 'rails' is empty in the raw_config.
4. It modifies the '_process_co_files' function to call '_add_main_co_file'.
5. It changes the '_add_main_co_file' function to append 'llm' to the libraries
   and add the main flow.
6. It changes the '_rails_co_file_path' from '_rails.co' to 'rails.co'.
@drazvan drazvan changed the base branch from develop to feature/colang-2.0-library August 22, 2024 10:11
@drazvan drazvan merged commit d6f8138 into feature/colang-2.0-library Aug 22, 2024
3 checks passed
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.

2 participants