Skip to content

Conversation

@yungyuc
Copy link
Member

@yungyuc yungyuc commented Oct 28, 2022

Address #103

Change the start-up code so that the viewer binary can run in the following 4 modes:

  1. viewer: open a windows
  2. command: take a string as Python code
  3. terminal: start text-based iPython prompt
  4. pytest: run the Python test cases

In this way, the viewer binary can be used to run the Python test cases. A new target run_viewer_pytest is added to the make file. CI (Ubuntu, macos, and Windows) uses the new target to run unit tests.

Change the start-up code so that the viewer binary can run in the following 4 modes:
1. viewer: open a windows
2. command: take a string as Python code
3. terminal: start text-based iPython prompt
4. pytest: run the Python test cases

In this way, the viewer binary can be used to run the Python test cases.  A new target run_viewer_pytest is added to the make file.  CI (Ubuntu, macos, and Windows) uses the new target to run unit tests.
@yungyuc yungyuc added the enhancement New feature or request label Oct 28, 2022
@yungyuc yungyuc self-assigned this Oct 28, 2022
run: |
cmake --build ${{ github.workspace }}/build `
--config ${{ matrix.cmake_build_type }} `
--target run_viewer_pytest
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit testing on Windows is now running, but the return code is not checked yet.

There is a minor error that can be fixed in the future when we change to respect the return code.


.PHONY: run_viewer_pytest
run_viewer_pytest: viewer
cmake --build $(BUILD_PATH) --target run_viewer_pytest VERBOSE=1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cmake target. This should be more robust. Other make file targets should change to be like this in the future.

// Initialize the Python interpreter.
modmesh::python::Interpreter::instance()
.initialize()
.setup_modmesh_path();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the setup code to distinct functions.


Interpreter & Interpreter::setup_process(int argc, char ** argv_in)
{
std::vector<std::string> argv;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a prototype implementation. Better organization should be done in the future.

},
py::arg("filename"))
.def(
"app",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it to be a function so that it always get the singleton from C++.

self.exited_status = None
self.exited_message = None

def exit(self, status=0, message=None):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Override to avoid calling sys.exit.

return pytest.main(['-v', '-x', mmpath])


def setup_process(argv):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup_process is probably not a good name because the role is the main function. But let's use it for now.

@tigercosmos
Copy link
Collaborator

there is a bug, even if I clean up the code in the interpreter and run it, the graph result is still there.
Also, I think it's better to have a console window with the interpreter.

@tigercosmos
Copy link
Collaborator

Actually, I think improving the interpreter could be a good project. probably can open another issue. like and the syntax highlight or something.

@yungyuc yungyuc merged commit b717c8b into solvcon:master Oct 28, 2022
@yungyuc
Copy link
Member Author

yungyuc commented Oct 28, 2022

there is a bug, even if I clean up the code in the interpreter and run it, the graph result is still there.
Also, I think it's better to have a console window with the interpreter.

Look forward to a PR. This PR is merged and it should be easier for you to work on it.

@yungyuc yungyuc deleted the feature/viewer-as-interpreter branch October 28, 2022 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants