julia编写dll
Imagine yourself working as data analyst in a company. You get different king of ad-hoc analysis request every day. To resolve those request you are using several programming tools (Dataframe, Distribution etc.), querying to databases. At the end of the projects you also git your code so that you can use it further when it needs or you can share you code to other colleagues when they need or may be your project should be in QA (git) before it sent to the clients.
我想像一下自己在一家公司担任数据分析师。 您每天都会收到不同的临时分析请求之王。 为了解决这些请求,您正在使用几种编程工具(Dataframe,Distribution等),查询数据库。 在项目结束时,您还可以混合代码,以便在需要时可以进一步使用它,或者可以在需要时与其他同事共享代码,或者您的项目应该在质量检查(git)中,然后再发送给客户。
But the project has a start and where to start?: You might want to have a folder JuliaProjects where you have a folder adhocs and folders for each projects such as 2020–07–18_My_Fancy_Project_xyz and there is a file code.jl where you have written all your code
但是该项目有一个起点,从哪里开始?:您可能想要一个文件夹JuliaProjects,其中每个项目都有一个文件夹adhocs和文件夹,例如2020–07–18_My_Fancy_Project_xyz,并且在其中编写了文件code.jl您所有的代码
What about the data you are going to download?: Ok. You can have another folder called datalake inside of adhocs where you store the data for each projects separately with the same signature name like project (2020–07–18_My_Fancy_Project_xyz) as you do not want to git the data
那您要下载的数据呢? 您可以在adhocs内有一个名为datalake的文件夹,您可以在每个文件夹中使用相同的签名名称(例如project( 2020–07–18_My_Fancy_Project_xyz ))分别存储每个项目的数据,因为您不想混用数据
What about the visuals and final report? Well, you can have a folder called insights inside of adhocs and you will store the visuals and data like the same fashion like datalake.
视觉效果和最终报告呢? 好了,你可以有一个文件夹,名为见解 adhocs的内部,你会在视觉效果和数据存储一样以同样的方式像datalake。
Lets see a tree structure of my won adhoc project folder inside of JuliaProjects folder:
让我们看一下JuliaProjects文件夹中我赢得的adhoc项目文件夹的树结构:
├── datalake
│ └── 2020–07–18_My_Fancy_Project_xyz
├── insights
│ └── 2020–07–18_My_Fancy_Project_xyz
│ ├── datafiles
│ └── vizfiles
└── projects
└── 2020–07–18_My_Fancy_Project_xyz
└── code.jl
Now will you create those files manually every time? How would you keep track the directory every time you close and open the same project? That’s why I came up with that idea of writing a project manager for ad hoc analysis. I have the same package for python which I never published but I used almost everyday. I though that would be a great learning experience If I re-create the same package in Julia and here is my package. If you like it, giving a start will be appreciated.
现在,您将每次手动创建这些文件吗? 每次关闭并打开同一项目时,如何跟踪目录? 这就是为什么我想到了写一个专案分析项目经理的想法。 我有一个从未发布过的python相同的软件包,但几乎每天都使用。 但是,如果我在Julia中重新创建相同的程序包,这将是很棒的学习经验, 这是我的程序包 。 如果您喜欢,请给个开始。
First let’s see the package efficiency from user point of view. To get started with the package we
首先让我们从用户的角度来看包装效率。 要开始使用该软件包,我们
First need to add the package with
] add ProjectFlow
orPkg.add(ProjectFlow)
首先需要使用
] add ProjectFlow
或Pkg.add(ProjectFlow)
添加软件包We have to create a profile which ProjectFlow will use
我们必须创建一个供ProjectFlow使用的配置文件
We have to create a profile which ProjectFlow will use
touch /home/username/.projectflow/profile
and add the following configs我们必须创建一个配置文件,ProjectFlow将使用
touch /home/username/.projectflow/profile
并添加以下配置
[default]
project_root=/home/datapsycho/JuliaProjects/adhocs
projects_dir=projects
data_dir=datalake
insights_dir=insights
insights_viz_dir=vizfiles
insights_data_dir=datafiles
It tells where is my project root, where the code file will be saved, where the data files, reports and visuals will be saved. But you can add more profiles if you want. Now lets use the Package (Current version of the package do not have support for windows, as I do not have any windows machine I could not test it, Someone interested can fork it and test it for windows machine).
它告诉我项目的根目录在哪里,代码文件将保存在哪里,数据文件,报告和可视化文件将在哪里保存。 但是,您可以根据需要添加更多配置文件。 现在让我们使用软件包(当前版本的软件包不支持Windows,因为我没有任何无法测试的Windows机器,有兴趣的人可以将其分叉并在Windows机器上进行测试)。
To use the Profile we can have common Julia environment inside of adhoc folder and code file lets say initializer.jl
with the following code.
要使用配置文件,我们可以在adhoc文件夹和代码文件中使用通用的Julia环境,让我们使用以下代码来声明initializer.jl
。
using ProjectFlow
p = Project(
id="xyz",
name="My Fancy? *Project1 2 ",
template="jl",
profile="default"
)
datalake, iviz, idata = initiate(p)
After we activate the environment, Filling up the entities of type a value of type Project (id: unique id of the project, name: full name of the project, template: the file extension to create a code.jl template and profile: the profile to use from config) and execution of initiate(p)
will create all the necessary folder structure showed in the first tree view and also a code.jl file inside of the new project folder with the following code. In future I have a plant to add notebook template if the user want to create notebook instead with all the template code:
激活环境后,填充类型为Project类型的值的实体(id:项目的唯一ID,name:项目的全名,template:创建代码的文件扩展名。jl template和profile:the要从config中使用的配置文件)并执行initiate(p)
将创建第一个树视图中显示的所有必需的文件夹结构,以及新项目文件夹内的code.jl文件,其中包含以下代码。 将来,如果用户要使用所有模板代码创建笔记本,我将拥有一个添加笔记本模板的工厂:
# Project Name:
# Regular Imports
using ProjectFlow
p = Project(
id="xyz",
name="My Fancy? *Project1 2 ",
template="jl",
profile="default"
)
datalake, idata, iviz = initiate(p)
Every time we close the Julia and open the project again and run the following code it will load all the necessary file path to save the data, visuals and raw data. So All three questions I asked at the beginning is automated now. If you want to save some data to disk you can use joinpath(datalake, "myfile.csv")
to store the data as datalake already loaded the path /home/datapsycho/JuliaProjects/adhocs/dataleke/2020–07–18_My_Fancy_Project_xyz/
in to your current environment. You can read more detail in the package doc.
每次我们关闭Julia并再次打开项目并运行以下代码时,它将加载所有必需的文件路径以保存数据,视觉效果和原始数据。 因此,我一开始问的所有三个问题现在都是自动化的。 如果要将一些数据保存到磁盘,则可以使用joinpath(datalake, "myfile.csv")
将数据存储为datalake已加载路径/home/datapsycho/JuliaProjects/adhocs/dataleke/2020–07–18_My_Fancy_Project_xyz/
适应您当前的环境。 您可以在打包文档中阅读更多详细信息。
Now Lets talk about about the experience of writing the package. I have started learning Julia beginning of this year, so I was very new to Julia. I must say the Julia Community is fantastic, all my queries has been answered in a very short time and I was getting Guidance from the community time to time.
现在让我们谈谈编写程序包的经验。 我从今年年初开始学习Julia,所以我对Julia很陌生。 我必须说茱莉亚社区很棒,我的所有查询都在很短的时间内得到了回答,我不时得到社区的指导。
To start writing package I have looked through several packages already created and also read the package writing part from the book Julia Programming Projects and Hands-On Design Patterns and Best Practices with Julia. But later I found the PackageTemplates.jl that makes my work much easier.
为了开始编写程序包,我浏览了已经创建的几个程序包,还阅读了《 Julia编程项目和动手设计模式以及与Julia的最佳实践》一书中的程序包编写部分。 但是后来我发现PackageTemplates.jl使我的工作更加轻松。
Julia packages is little bit different than python. In python you would create a directory with __init__.py
file and will be considered as module later you can use setup tool to create whl
file from the module and you will be able to install the wheel file using pip. Your dependency can be added to setup.py
file or pip.lock
file.
Julia软件包与python有点不同。 在python中,您将使用__init__.py
文件创建一个目录,并将其视为模块,以后您可以使用安装工具从该模块创建whl
文件,并且可以使用pip安装wheel文件。 您的依存关系可以添加到setup.py
文件或pip.lock
文件中。
But julia package system is different. As we can see in that tree map, A inside view of my ProjectFlow folder:
但是茱莉亚的包裹制度是不同的。 正如我们在该树形图中所看到的,我的ProjectFlow文件夹的内部视图:
.
├── LICENSE
├── Manifest.toml
├── Project.toml
├── README.md
├── src
│ ├── loader.jl
│ ├── logger.jl
│ ├── manager.jl
│ ├── ProjectFlow.jl
│ ├── project.jl
│ └── template.jl
├── temp
│ ├── codecove.txt
│ └── projects.log
└── test
├── exporttests.jl
└── runtests.jl
All of your main code lies inside of src
folder (I am new, so still do not know if that a standard) The toml
files are for dependency management, I am not going to discuss in details about which toml
is for what purpose. Now it comes to src
. As you can see ProjectFlow.jl
file is the main file for user to import the library and all other files are just separated based on functionality. Julia have spacial keyword for modules which you will find in the ProjectFlow.jl
file. Community suggest you should only use module when you really need. You can see more details about the answers of my questions in discourse. There is no creating wheel files, after adding your Package in GitHub and Julia Hub Repository, You will be able to install it using Pkg
directly from GitHub or Julia Hub Repository.
您所有的主要代码都位于src
文件夹中(我是新手,所以仍然不知道是否有标准) toml
文件用于依赖关系管理,我不会详细讨论哪个toml
是用于什么目的的。 现在谈到src
。 如您所见, ProjectFlow.jl
文件是用户导入库的主要文件,而所有其他文件只是根据功能分开。 Julia为模块提供了空间关键字,您可以在ProjectFlow.jl
文件中找到它们。 社区建议您仅在真正需要时才使用模块。 您可以在话语中看到有关我的问题的答案的更多详细信息。 在GitHub和Julia Hub存储库中添加软件包后,没有创建wheel文件,您将能够直接从GitHub或Julia Hub存储库中使用Pkg
安装它。
Just to give an example how I separate the code for example: Every time we create a project that project info is logged in /home/datapsycho/.projectflow/projects.log
file, so that functionality is in the logger.jl
file lated the logger.jl
is included into ProjectFlow.jl
with spacial keyword include("logger.jl")
and used.
举例来说,我是如何分离代码的:例如,每次创建项目时,项目信息都会记录在/home/datapsycho/.projectflow/projects.log
文件中,因此功能在logger.jl
文件中, logger.jl
通过空间关键字include("logger.jl")
包含在ProjectFlow.jl
并使用。
The first problem I have encountered with when creating package is CICD and documentation creation. But after having a look on other packages which resolves too, here is a little bit backdated video by Chris from MIT on creating packages (he is awesome!). The next problem was getting a tag and creating an issue to add the package in Julia Hub. Mosè Giordano from community jumped and saved my day, I am really thankful to him.
我已创建包时所遇到吨他的第一个问题是CICD和文档的创建。 但有其他的包一看它解决过之后, 这里是创建包一点点追溯视频克里斯麻省理工学院(他是真棒!)。 下一个问题是获取标签并创建问题以将包添加到Julia Hub中。 来自社区的 MosèGiordano 跳了起来 ,救了我一整天,我真的很感谢他。
Over all It was really a good experience. Every time I felt in to some issue the Julia Community jumped in and help me. Now I feel like its my duty too to help the others. Thanks To Julia Community.
Ø版本所有这真是一个很好的经验。 每当我遇到某个问题时,Julia社区都会加入并为我提供帮助。 现在,我觉得自己也有责任帮助其他人。 感谢Julia社区。
Package Development in Julia is different than development in Python I must say. But It has all the tools pre-built (PackageTemplates, test etc.) to get you started and there is always someone in Julia Community is going to help on the way. I never felt alone on that journey.
我必须说,Julia中的包开发与Python中的开发不同。 但是它具有预先构建的所有工具(PackageTemplates,测试等),可以帮助您入门,并且Julia Community中总会有人在此途中提供帮助。 我从未在旅途中感到孤单。
julia编写dll