Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Packages sorted by activeDisplay the line number in a mathematica package?
https://community.wolfram.com/groups/-/m/t/1592936
for example ,
BeginPackage[ "Package`"]
MainFunction::usage =
"MainFunction[ x] computes a simple function."
Begin[ "Private`"]
MainFunction[ x_] :=
Module[ {y},
y = x^2;
y + 1
]
End[]
EndPackage[]
i don't know how to display the line number in a mathematica's .m file. Thank you in advance!zhu xiaoming2019-01-16T09:03:58ZHow to use Mathematica in a high-performance computing (HPC) environment
https://community.wolfram.com/groups/-/m/t/984003
I'm going to show you how you can use existing functionality to run a Mathematica script across a managed HPC cluster. Before I start, I must be upfront with you: though the individual commands are documented, this method, as a whole, is not. Thus, support for this procedure is outside the scope of Wolfram Technical Support. However, I'm hoping that once the ground-work has been laid, that Wolfram Community members can work together to fill in the missing details.
My assumptions:
1. Mathematica is installed and properly licensed on the managed cluster
2. once your job has been given resources, that you can freely SSH between them
(1) This is up to your local cluster's System Admin to figure out by talking with their organization and a Wolfram Sales Representative, and possibly Wolfram Technical Support ([support.wolfram.com][1]).
(2) Again, this is up to your local SysAdmin to ensure. It's also known as a public/private key pair between nodes.
In the following, I'm assuming the cluster uses Torque ([Torque SysAdmin Guide][2]), but in principle other managers can be used. A generic Mathematica script job submission may look like the following:
#PBS -N Job_name
#PBS -l walltime=10:30
#PBS -l nodes=4:ppn=6
#PBS -m be
math -script hpc.wl
In this example,
- the job is called "Job_name"
- the job will finish in 10 and a half minutes
- it is requesting 4 nodes with 6 processors-per-node, for a total of 24 resources (CPU cores)
- an email will be sent to the account associated with the username when the job (b)egins and when it (e)nds
If you are not familiar with job submissions to a managed HPC cluster, then I suggest you read any guides provided by your organization
The Wolfram Language script "hpc.wl" does the rest of the work. It generically follows this order:
1. gather the environment variables associated with the list of provided resources
2. launch remote subkernels for each CPU core
3. do the parallel computations
4. close the subkernels
5. end the job
(*get association of resources, name of local host, and remove local host from available resources*)
hosts = Counts[ReadList[Environment["PBS_NODEFILE"], "String"]];
local = First[StringSplit[Environment["HOSTNAME"],"."]];
hosts[local]--;
(*launch subkernels and connect them to the controlling Wolfram Kernel*)
Needs["SubKernels`RemoteKernels`"];
Map[If[hosts[#] > 0, LaunchKernels[RemoteMachine[#, hosts[#]]]]&, Keys[hosts]];
(* ===== regular Wolfram Language code goes here ===== *)
Print[ {$MachineName, $KernelID} ]
(* ===== end of Wolfram Language program ===== *)
CloseKernels[];
Quit
On Torque there is the environment variable "PBS\_NODEFILE" ([Torque environment variables][3]) that lists the different nodes that are provided to the job. It is my understanding that the name is repeated for each CPU core. That's why a simple Count of the node list tells us everything. The other piece of information, which is probably not necessary, is "HOSTNAME". This is where the Wolfram controlling kernel is running. In the above, we remove it from the list of available resources, but I don't believe this is necessary. According to the documentation ([3]), this may be known as "PBS\_O\_HOSTNAME".
The Mathematica script should not need to change save for the code between the commented lines. I'm also assuming that `$RemoteCommand` (provided by Subkernels\`RemoteKernels\`) is the same on each node. This is usually the case as most clusters use a cloned file system.
SLURM should be very similar except that the environment variables will be different. It is my understanding that
headNode = Environment["SLURMD_NODENAME"];
nodes = ReadList["!scontrol show hostname $SLURM_NODELIST",String];
provides the headnode and list of resources.
I encourage discussion.
[1]: http://support.wolfram.com
[2]: http://docs.adaptivecomputing.com/torque/4-0-2/help.htm
[3]: http://docs.adaptivecomputing.com/torque/4-0-2/help.htm#topics/2-jobs/exportedBatchEnvVar.htmKevin Daily2016-12-19T21:29:53ZMathematica Package Repository (Paclet Server) Updates
https://community.wolfram.com/groups/-/m/t/1575086
__The server is open for submissions. Please do. All you have to do is fill out [a form](https://paclets.github.io/PacletServer/pages/submit.html).__
---
A while back I posted here about a paclet server, which is to say a repository for Mathematica packages which people can easily install and use
The key, here, is the *easily*. As in single-line installation and integrated with all of Mathematica's standard tools.
[![enter image description here][1]](https://paclets.github.io/PacletServer/)
The server is [hosted on GitHub](https://github.com/paclets) and so everything is open source and anyone can contribute. The deployment is done with GitHub pages as [the cloud is still insufficient](https://community.wolfram.com/groups/-/m/t/1485141) for a number of reasons. There is also a [GitHub Wiki](https://github.com/paclets/PacletServer/wiki) that provides notes on how you can install from the server, upload to the server, etc.
This server has been slowly evolving over the past just-under-a-year as I get a better handle on how to make it easier to add paclets, easier to customize, and nicer in general.
I decided to start this thread to track this progress in a place that Mathematica users would see.
Any suggestions people can provide are greatly appreciated and feel free to communicate with [us on Gitter](https://gitter.im/paclets/community#) for potentially faster discussion.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=3804blah.png&userId=1186441b3m2a1 2018-12-20T08:22:16ZSimplifying (Making) Mathematica Documentation
https://community.wolfram.com/groups/-/m/t/1592149
The Documentation Center is nice. The docs are reasonably complete. Stuff is somewhat searchable. It looks really nice. But if you've ever made your own system for generating these kinds of docs you know it's a *lot* of work. The notebooks are unnecessarily complicated. There are cutesy little elements here and there that don't really buy us much.
I wanted something cleaner that would be easier to write, more transparent, and, crucially, more distributable. What I came up with was the [SimpleDocs](https://paclets.github.io/PacletServer/simpledocs.html#main-content) package.
[![enter image description here][1]](https://paclets.github.io/PacletServer/simpledocs.html#main-content)
I'll write a more extended example soon and once the interface has gelled completely, but I want to show off what it can do for us, entirely automatically. To do so I decided to make documentation for my (admittedly a little bloated) package development package [BTools](https://paclets.github.io/PacletServer/btools.html#main-content).
The first thing I did was start a new project from the `SimpleDocs` interface (I'll document that later so it's easy to follow along). The build folder started out much simpler (but I didn't have to do much of anything for it!) but here's what it looks like now:
![enter image description here][2]
I'm making two things in tandem, on the one hand I'm making docs that integrate nicely with the documentation center. Here's an example of what I get when searching for `WebSiteBuild` locally:
![enter image description here][3]
It looks a lot like WRI docs (excluding the fact that I only have autogenerated content and the "Details" are hidden), but there are a few key differences, the big two being that it's much, much simpler internally and it's *version independent*. I package my own stylesheet with the docs, so they can be used cross version without issue and without looking terrible.
All the content in that notebook was generated automatically, though. I didn't write any of it (and there are lots of details and options you don't see here). In fact, I actually generated *all* of the function docs automatically, and now I can go back and more fully document the big ones at my leisure. There is also a tutorial on how this works in the `SimpleDocs` docs.
At the same time as I build the docs notebooks I also built out .md files for each docs page. This is nice because these can then be fed into any number of website generators to make nice docs websites. Here's the website I built for BTools that comes automatically from `SimpleDocs` (again, this will be documented more thoroughly in the coming weeks):
[![enter image description here][4]](https://www.wolframcloud.com/objects/b3m2a1.docs/BTools/)
In this there's an [index of functions](https://www.wolframcloud.com/objects/b3m2a1.docs/BTools/index/functions.html) and if I had guides or tutorials yet there'd be an index for both of those as well.
You can also [search for keywords] (https://www.wolframcloud.com/objects/b3m2a1.docs/BTools/search.html?q=App) which is powered by [tipuesearch](http://www.tipue.com/search/):
[![enter image description here][5]](https://www.wolframcloud.com/objects/b3m2a1.docs/BTools/search.html?q=App)
And there is much, much more I could do with this website and things. At the moment I'm really just scraping the very most basic stuff of what I can automatically do without *any* real effort on my part (except for in development).
Hopefully this has shown that Mathematica docs can be simpler and, once I've finished using this package to document itself, can be simpler to make for anyone. As I said, I'm hoping to get this done and finalized in the next few weeks and once that is through I will write here again (and write a blog post) detailing how you can easily use it for yourself.
In the meantime here's a video of the documentation for BTools being autogenerated:
[![enter image description here][6]](https://www.youtube.com/watch?v=4lTrMwHCjyU)
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5722urg.png&userId=1186441
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=hmm.png&userId=1186441
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=meep.png&userId=1186441
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5444meh.png&userId=1186441
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=bleep.png&userId=1186441
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=yt.png&userId=1186441b3m2a1 2019-01-15T02:42:56ZUse package "Calculus`VectorAnalysis`" ?
https://community.wolfram.com/groups/-/m/t/1587220
I am trying to:
Needs["Calculus``VectorAnalysis`"]
But it Failed and the error messages say:
Cannot open Calculus'VectorAnalysis' and Context Calculus'VectorAnalysis' was not created when Needs was evaluated. Does anyone know how I can get that package?Yunlin Zeng2019-01-11T01:13:14Z