Skip to content

Commit

Permalink
voxec.SILENT flag to silence progress print during commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Nov 4, 2024
1 parent c007af6 commit 4127d6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
16 changes: 15 additions & 1 deletion module/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
from .voxec import *
from .voxec import *

import multiprocessing

default_VOXELSIZE = 0.05
default_CHUNKSIZE = 16
default_THREADS = multiprocessing.cpu_count()
SILENT = False

def run(name, *args, **kwargs):
ctx = context()
ctx.set('VOXELSIZE', default_VOXELSIZE)
ctx.set('CHUNKSIZE', default_CHUNKSIZE)
ctx.set('THREADS', default_THREADS)
return run_(name, args, kwargs, ctx, SILENT)
19 changes: 2 additions & 17 deletions wrap/wrapper.i
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,14 @@ struct context {
}
};

symbol_value run_(const std::string& name, PyObject *args, PyObject *kwargs, context* ctx = nullptr) {
symbol_value run_(const std::string& name, PyObject *args, PyObject *kwargs, context* ctx = nullptr, bool silent=false) {
scope_map scope;
if (ctx) {
scope = ctx->scope;
}

voxel_operation* op = voxel_operation_map::create(name);
op->silent = silent;

// Process positional arguments
auto it = op->arg_names().begin();
Expand Down Expand Up @@ -333,21 +334,5 @@ symbol_value run_(const std::string& name, PyObject *args, PyObject *kwargs, con

%}

%pythoncode %{

import multiprocessing

default_VOXELSIZE = 0.05
default_CHUNKSIZE = 16
default_THREADS = multiprocessing.cpu_count()

def run(name, *args, **kwargs):
ctx = context()
ctx.set('VOXELSIZE', default_VOXELSIZE)
ctx.set('CHUNKSIZE', default_CHUNKSIZE)
ctx.set('THREADS', default_THREADS)
return run_(name, args, kwargs, ctx)
%}

%module voxec %{
%}

0 comments on commit 4127d6a

Please sign in to comment.