Comments (5)
If you think I'm using the code wrong, please let me know.
additionally to alberts suggestion above (which provides a positional arg to fill a positional arg formatting slot) I would offer
returnn.config.CodeWrapper(
DelayedFormat(
"lambda files: get_sub_epoch_dataset(files, dataset={dataset}, num_workers={num_workers}, local_caching={local_caching})",
dataset=dataset_copy,
num_workers=num_workers,
local_caching=local_caching,
)
),
which uses kwargs for both the formatting string and the arguments to str.format
.
There's no way any keyword arguments will be respected in the formatting function. Moreover, if I remember correctly the dictionary composed of the kwargs isn't guaranteed to have the right order before python 3.something (3.7?), so kwargs.values() wouldn't work either.
In this case you are responsible yourself that the kwargs defined in the formatting string match those that are passed to the function. If they match, then the order would not matter.
(dicts are sorted in order of insertion in python3.6+)
from sisyphus.
I don't exactly understand why you think there is any issue in DelayedFormat
. This exception is exactly what you would expect here. All is correct. If you want to use kwargs this way, the Python str.format
works this way:
"{a}.format(a="a")
The example with CodeWrapper
I gave before (here) was slightly wrong, it should be like this:
CodeWrapper(DelayedFormat('lambda files: get_sub_epoch_dataset(files, **({}))', whatever_extra_kwargs_you_want))
from sisyphus.
I see, I didn't know that the formatted string should have the kwarg keyword between braces, thanks for clarifying.
I just tried what I show below:
returnn.config.CodeWrapper(
DelayedFormat(
"lambda files: get_sub_epoch_dataset(files, **({})", dataset=dataset_copy, num_workers=num_workers, local_caching=local_caching,
)
),
But I still get the error IndexError: Replacement index 0 out of range for positional args tuple
. Perhaps I'm still using it wrong?
from sisyphus.
Yes it's exactly wrong in the same way? You are using here a positional arg ({}
is a positional arg, i.e. not a keyword arg; it refers to the first positional arg) but then you only provide keyword args? Of course that's wrong. For example, you could do it like this:
returnn.config.CodeWrapper(
DelayedFormat(
"lambda files: get_sub_epoch_dataset(files, **({}))",
dict(dataset=dataset_copy, num_workers=num_workers, local_caching=local_caching),
)
),
from sisyphus.
Thanks for the feedback everyone. I'll close this issue since the error was mine.
Edit: just to clarify, everything is working as intended, I just had to set the string to what @michelwi said above.
from sisyphus.
Related Issues (20)
- Sisyphus fails to hash numpy bools HOT 1
- Sisyphus sometimes hangs for a while (several minutes) at startup HOT 11
- Suggestion: Database for cache, `_sis_all_path_available` etc
- AssertionError: Only runnable jobs can list needed tasks HOT 1
- Local job hangs, not available input HOT 2
- Job marked in error state is actually running HOT 2
- More then one matching SLURM task (again) HOT 1
- Auto-restart hanging job if faulty node detected HOT 11
- Possibility to set specific env vars for job HOT 13
- Auto-restart jobs on user-specified error conditions HOT 1
- `Unsupported operand type(s) for *` when running `tk.remove_job_and_descendants(mode="move")` HOT 7
- `sis_hash_helper` on `enum.Enum`s is Python version dependent HOT 2
- Too many open file descriptors HOT 5
- Use `dill` for pickling HOT 2
- Drop older Python support / increase min required Python version
- Incorrect type annotations for rqmt in task.py HOT 3
- Task's resume function is ignored HOT 5
- Handling of requeueing in SLURM HOT 2
- Hooking job exit/failure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sisyphus.