Comments (6)
For my understanding, what's the motivation for wanting to change this value? Reports with high number of elements getting id collisions?
from pybloqs.
Moving it into the user_config is trivial and would achieve the desired effect.
from pybloqs.
There are actually a few things about file savings which may be good for other but don't follow my use pattern.
The _id method is using uuid but this is uninformative to the user, I have changed it in my own branch to self._id = datetime.datetime.now().utcnow().strftime('%Y%m%d%H%M%S%f')
At this point ID_PRECISION does need to be set a little higher, but we do get meaningful sort on filename. Indeed, when I send an email, by knowing when the email was sent, I can then find the file and ''similar versions I didn't send but looked at'' in the temp dir really easily. Admittedly, sorting by date does the same thing, so I am perhaps just being silly, but it does make my life a little easier.
The other annoying thing is the save method... The tempdir is set in stone and cannot be overwritten.
tempdir = tempfile.gettempdir() #line 141 of block/base.py
Strangely, I would have thought both .show() and .save() and indeed .email() should really follow a similar pattern and write to similar locations. In my own usage pattern, all generate 'throw aways temp files' but what I like to do is to keep all the data in one place and then delete judiciously
Finally, and completely unrelated, the convenience Block method isn't quite as flexible as I need it, throwing exceptions e.g. for dicts or pd.Series. Here is my own, more convenient method :-)
def block(contents=None, title=None, title_level=3, title_wrap=False, inherit_cfg=True, **kwargs):
"""
Constructs a composable layout element that will be rendered automatically by
IPython Notebooks. It can also be saved in HTML, PDF, PNG or JPEG formats.
Content is handled as follows:
- Lists are written out into a grid layout, with a single column
- tuples are written out into a grid layout, with a single row
- DataFrames are written out as an interactive HTML table.
- Strings are written out in a raw format, preserving any HTML content in them.
- Nested blocks are simply wrapped, unless there is more than one in which case
the same logic applies as for lists, tuples and sets.
:param contents: Contents to put in a block.
:param title: Optional title of the block.
:param title_level: Optional title level (adjusts the size and TOC level), 1 being the
biggest and 9 being the smallest.
:param title_wrap: Toggles whitespace wrapping of the title. (Default: False).
:param inherit_cfg: Optional. Set to False to ensure that the block does not inherit
any parameters from parents.
:param cascade_cfg: Set to True to enable parmater cascading from this block. A value
of False means that child blocks do not inherit parameters from
this block.
:param kwargs: Optional styling arguments. The style
keyword argument has special
meaning in that it allows styling to be grouped as one argument.
It is also useful in case a styling parameter name clashes with a standard
block parameter.
:return: A block instance.
"""
if isinstance(contents, pybloqs.BaseBlock):
return contents
elif isinstance(contents, list):
return pybloqs.block.layout.Grid([block(c) for c in contents],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, tuple): # new but works like a treat...
return pybloqs.block.layout.HStack([block(c) for c in contents],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, dict):
return pybloqs.block.layout.Grid([block(tuple(item)) for item in contents.items()],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, pd.Series):
if len(contents)>0 and is_date(contents.index[0]):
return block(go.Scatter(x = contents.index, y = contents.values),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return block(dict(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, Figure): #plotly figure
return pybloqs.block.image.PlotlyPlotBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, BaseTraceHierarchyType): #like plotly.graph_objects.Scatter
return block(go.Figure(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, pd.DataFrame):
if len(contents)>0 and is_date(contents.index[0]): #TimeSeries, not really a table
return pybloqs.block.image.PlotlyPlotBlock(df_to_fig(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return pybloqs.block.table.HTMLJinjaTableBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, Artist):
return pybloqs.block.image.PlotBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return Raw(str(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
from pybloqs.
Dom, btw, why just pip and not conda? Doesn't this restrict target audience?
from pybloqs.
Added id_precision and tmp_dir to user_config as a drive-by of #68.
from pybloqs.
Re. conda: There was no demand for this yet. This would make a great contribution to the project as this is quite a standalone task.
from pybloqs.
Related Issues (20)
- Using pybloqs instructions: misnamed variable HOT 2
- Version Support and Platform Support HOT 3
- unit test failure - No such file or directory: 'PyBloqs/pybloqs/static/highstock.js' HOT 4
- Python3 support HOT 6
- Add option to add password for email server
- Support utf8 and allow bcc in emails
- Add a page break example HOT 1
- Make plotly and bokeh imports local, so the dependencies are fully optional.
- Remove pandas WidePanel HOT 2
- Example with DataTables? HOT 1
- How to add a theme to the html output? HOT 1
- HTML Converter Does Not Provide Enough Arguments To Format String HOT 2
- Use puppeteer-core and bundle with PyBloqs in static/ folder
- Cannot encode unicode characters when writing to pdf (python 2.7) HOT 4
- HTML converters leave temporary files around
- please add in conda repo
- Plotly and highcharts integration broken for Jupyter Notebook integration
- library doesn't work with pandas v2.0.x HOT 1
- Support for oauth2 for sending via Exchange Online / Office 365
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 pybloqs.