Skip to content

Commit c072ab1

Browse files
authored
Merge pull request #109 from cindytsai/Pre-v0.1
Prepare for release v0.1
2 parents ff40d10 + 3f10a7d commit c072ab1

File tree

8 files changed

+24
-28
lines changed

8 files changed

+24
-28
lines changed

doc/in-situ-python-analysis/jupyter-notebook/jupyter-notebook-access.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ We need another process to start Jupyter Notebook/JupyterLab and connect to liby
3939
4. Launch Jupyter Notebook/JupyterLab
4040
```bash
4141
jupyter notebook # launch Jupyter Notebook
42-
jupyter-lab # launch JupyterLab
42+
jupyter lab # launch JupyterLab
4343
```
4444
5. Click `Libyt` to connect to libyt kernel once the simulation is running and libyt kernel is activated.
4545

doc/in-situ-python-analysis/jupyter-notebook/remote-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Please go through [Login Node](#login-node) before going through [Local Laptop](
4747
2. Launch Jupyter Notebook / JupyterLab in no-browser mode with port `XXXX` and allowing access from other IP address (`--ip="0.0.0.0"`):
4848
```bash
4949
jupyter notebook --no-browser --port=XXXX --ip="0.0.0.0"
50-
jupyter-lab --no-browser --port=XXXX --ip="0.0.0.0"
50+
jupyter lab --no-browser --port=XXXX --ip="0.0.0.0"
5151
```
5252
Change `XXXX` to some unused port on login node, this is just a placeholder.
5353
3. You should see something like:

example/amr-example/example.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ int main(int argc, char* argv[]) {
208208
yt_set_UserParameterInt("mhd", 1, &mhd);
209209
const int srhd = 0;
210210
yt_set_UserParameterInt("srhd", 1, &srhd);
211+
const int opt_unit = 0;
212+
yt_set_UserParameterInt("opt_unit", 1, &opt_unit);
213+
const float mu = 0.6;
214+
yt_set_UserParameterFloat("mu", 1, &mu);
211215

212216
// demo of some other parameters we can add
213217
const int user_int = 1;

example/quick-start/quick-start.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ int main(int argc, char* argv[]) {
4343
// Execute Python functions and activate Python entry points
4444
// ==========================================================
4545
if (yt_run_Function("print_hello_world") != YT_SUCCESS) {
46+
fprintf(stderr, "ERROR: yt_run_Function failed!\n");
4647
exit(EXIT_FAILURE);
4748
}
4849

4950
if (yt_run_FunctionArguments("print_args", 3, "\'1\'", "2", "3.0") != YT_SUCCESS) {
51+
fprintf(stderr, "ERROR: yt_run_FunctionArguments failed!\n");
5052
exit(EXIT_FAILURE);
5153
}
5254

5355
// Activate Python prompt
5456
if (yt_run_InteractiveMode("LIBYT_STOP") != YT_SUCCESS) {
57+
fprintf(stderr, "ERROR: yt_run_InteractiveMode failed!\n");
5558
exit(EXIT_FAILURE);
5659
}
5760

@@ -67,6 +70,12 @@ int main(int argc, char* argv[]) {
6770
exit(EXIT_FAILURE);
6871
}
6972

73+
// Free and reset the state
74+
if (yt_free() != YT_SUCCESS) {
75+
fprintf(stderr, "ERROR: yt_free() failed!\n");
76+
exit(EXIT_FAILURE);
77+
}
78+
7079
// =======================================
7180
// Finalize libyt
7281
// =======================================

src/append_grid.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ static int set_particle_data(yt_grid* grid);
2323
// Return : YT_SUCCESS or YT_FAIL
2424
//-------------------------------------------------------------------------------------------------------
2525
int append_grid(yt_grid* grid) {
26-
SET_TIMER(__PRETTY_FUNCTION__);
27-
2826
// export grid info to libyt.hierarchy
2927
PyArrayObject* py_array_obj;
3028

@@ -76,8 +74,6 @@ int append_grid(yt_grid* grid) {
7674
// Return : YT_SUCCESS or YT_FAIL
7775
//-------------------------------------------------------------------------------------------------------
7876
static int set_field_data(yt_grid* grid) {
79-
SET_TIMER(__PRETTY_FUNCTION__);
80-
8177
yt_field* field_list = LibytProcessControl::Get().field_list;
8278

8379
PyObject *py_grid_id, *py_field_labels, *py_field_data;
@@ -179,8 +175,6 @@ static int set_field_data(yt_grid* grid) {
179175
// Return : YT_SUCCESS or YT_FAIL
180176
//-------------------------------------------------------------------------------------------------------
181177
static int set_particle_data(yt_grid* grid) {
182-
SET_TIMER(__PRETTY_FUNCTION__);
183-
184178
yt_particle* particle_list = LibytProcessControl::Get().particle_list;
185179

186180
PyObject *py_grid_id, *py_ptype_labels, *py_attributes, *py_data;

src/get_dtype_property.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
// Return : YT_SUCCESS or YT_FAIL
2626
//-------------------------------------------------------------------------------------------------------
2727
int get_npy_dtype(yt_dtype data_type, int* npy_dtype) {
28-
SET_TIMER(__PRETTY_FUNCTION__);
29-
3028
switch (data_type) {
3129
case YT_FLOAT:
3230
*npy_dtype = NPY_FLOAT;
@@ -103,8 +101,6 @@ int get_npy_dtype(yt_dtype data_type, int* npy_dtype) {
103101
// Return : YT_SUCCESS or YT_FAIL
104102
//-------------------------------------------------------------------------------------------------------
105103
int get_yt_dtype_from_npy(int npy_dtype, yt_dtype* data_dtype) {
106-
SET_TIMER(__PRETTY_FUNCTION__);
107-
108104
switch (npy_dtype) {
109105
case NPY_FLOAT:
110106
*data_dtype = YT_FLOAT;
@@ -173,8 +169,6 @@ int get_yt_dtype_from_npy(int npy_dtype, yt_dtype* data_dtype) {
173169
// Return : YT_SUCCESS or YT_FAIL
174170
//-------------------------------------------------------------------------------------------------------
175171
int get_mpi_dtype(yt_dtype data_type, MPI_Datatype* mpi_dtype) {
176-
SET_TIMER(__PRETTY_FUNCTION__);
177-
178172
switch (data_type) {
179173
case YT_FLOAT:
180174
*mpi_dtype = MPI_FLOAT;
@@ -258,8 +252,6 @@ int get_mpi_dtype(yt_dtype data_type, MPI_Datatype* mpi_dtype) {
258252
// Return : YT_SUCCESS or YT_FAIL
259253
//-------------------------------------------------------------------------------------------------------
260254
int get_dtype_size(yt_dtype data_type, int* dtype_size) {
261-
SET_TIMER(__PRETTY_FUNCTION__);
262-
263255
switch (data_type) {
264256
case YT_FLOAT:
265257
*dtype_size = sizeof(float);
@@ -343,8 +335,6 @@ int get_dtype_size(yt_dtype data_type, int* dtype_size) {
343335
// Return : YT_SUCCESS or YT_FAIL
344336
//-------------------------------------------------------------------------------------------------------
345337
int get_dtype_typeid(yt_dtype data_type, const std::type_info** dtype_id) {
346-
SET_TIMER(__PRETTY_FUNCTION__);
347-
348338
switch (data_type) {
349339
case YT_FLOAT:
350340
*dtype_id = &typeid(float);
@@ -430,8 +420,6 @@ int get_dtype_typeid(yt_dtype data_type, const std::type_info** dtype_id) {
430420
// Return : YT_SUCCESS or YT_FAIL
431421
//-------------------------------------------------------------------------------------------------------
432422
int get_dtype_allocation(yt_dtype data_type, unsigned long length, void** data_ptr) {
433-
SET_TIMER(__PRETTY_FUNCTION__);
434-
435423
switch (data_type) {
436424
case YT_FLOAT:
437425
*data_ptr = malloc(length * sizeof(float));
@@ -532,8 +520,6 @@ int get_dtype_allocation(yt_dtype data_type, unsigned long length, void** data_p
532520
//-------------------------------------------------------------------------------------------------------
533521
int big_MPI_Get_dtype(void* recv_buff, long data_len, yt_dtype* data_dtype, MPI_Datatype* mpi_dtype, int get_rank,
534522
MPI_Aint base_address, MPI_Win* window) {
535-
SET_TIMER(__PRETTY_FUNCTION__);
536-
537523
switch (*data_dtype) {
538524
case YT_FLOAT:
539525
return big_MPI_Get<float>(recv_buff, data_len, mpi_dtype, get_rank, base_address, window);

src/libyt_kernel.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ void LibytKernel::configure_impl() {
3232

3333
PyObject* py_module_jedi = PyImport_ImportModule("jedi");
3434
if (py_module_jedi == NULL) {
35-
log_info("Unable to import jedi, jedi auto-completion library is disabled\n");
36-
log_info("See https://jedi.readthedocs.io/ \n");
35+
log_info(
36+
"Unable to import jedi, jedi auto-completion library is disabled (See https://jedi.readthedocs.io/)\n");
3737
m_py_jedi_interpreter = NULL;
3838
} else {
3939
m_py_jedi_interpreter = PyObject_GetAttrString(py_module_jedi, "Interpreter");
@@ -68,7 +68,7 @@ nl::json LibytKernel::execute_request_impl(int execution_counter, const std::str
6868
bool store_history, nl::json user_expressions, bool allow_stdin) {
6969
SET_TIMER(__PRETTY_FUNCTION__);
7070

71-
std::string cell_name = std::string("In [") + std::to_string(execution_counter) + std::string("]");
71+
std::string cell_name = std::string("<In [") + std::to_string(execution_counter) + std::string("]>");
7272

7373
// Find if '%' is the first non-space character, if so, redirect jobs to define command
7474
std::size_t found = code.find_first_not_of("\t\n\v\f\r ");
@@ -187,8 +187,8 @@ nl::json LibytKernel::complete_request_impl(const std::string& code, int cursor_
187187

188188
// Check if jedi has successfully import
189189
if (m_py_jedi_interpreter == NULL) {
190-
log_info("Unable to import jedi, jedi auto-completion library is disabled\n");
191-
log_info("See https://jedi.readthedocs.io/ \n");
190+
log_info(
191+
"Unable to import jedi, jedi auto-completion library is disabled (See https://jedi.readthedocs.io/)\n");
192192
return xeus::create_complete_reply({}, cursor_pos, cursor_pos);
193193
}
194194

@@ -325,7 +325,7 @@ nl::json LibytKernel::kernel_info_request_impl() {
325325
// helper
326326
libyt_kernel_info["help_links"] = nl::json::array();
327327
libyt_kernel_info["help_links"][0] =
328-
nl::json::object({{"text", "libyt Kernel Documents"}, {"url", "https://yt-project.github.io/libyt/"}});
328+
nl::json::object({{"text", "libyt Kernel Documents"}, {"url", "https://libyt.readthedocs.io/en/latest/"}});
329329

330330
// status
331331
libyt_kernel_info["status"] = "ok";

src/libyt_python_shell.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ CodeValidity LibytPythonShell::check_code_validity(const std::string& code, bool
469469

470470
CodeValidity code_validity;
471471

472+
// clear error buffer before redirecting stderr
473+
PyErr_Clear();
472474
PyRun_SimpleString("import sys, io\n");
473475
PyRun_SimpleString("sys.OUTPUT_STDERR=''\nstderr_buf=io.StringIO()\nsys.stderr=stderr_buf\n");
474476

@@ -561,6 +563,7 @@ std::array<AccumulatedOutputString, 2> LibytPythonShell::execute_cell(const std:
561563
#endif
562564

563565
// Clear the template buffer and redirect stdout, stderr
566+
PyErr_Clear();
564567
PyRun_SimpleString("import sys, io\n");
565568
PyRun_SimpleString("sys.OUTPUT_STDOUT=''\nstdout_buf=io.StringIO()\nsys.stdout=stdout_buf\n");
566569
PyRun_SimpleString("sys.OUTPUT_STDERR=''\nstderr_buf=io.StringIO()\nsys.stderr=stderr_buf\n");

0 commit comments

Comments
 (0)