Direct2Cad Workspace¶
A workspace is an isolated environment for SWRi's direct2cad scripts to run in. Various tasks will run in a workspace and have their results bundled into a zip file for use by clients.
Basic Workspace Operation¶
In order to describe how operations occur in a workspace we need to define a few concepts:
- Workspace: An isolated environment, in practice a file folder, in which direct2cad operations are run.
- Session: A set of operations, python and console commands, that are run within a workspace to do something, usually processing a design with direct2cad.
- Reference Workspace: This is a static, read-only workspace which is used to initialize a session.
- Active Workspace: The workspace that is currently running a session.
- Result Archive: A zip file that contains all the output from a session.
The flow is as follows:
sequenceDiagram
autonumber
participant S as Session
participant A as Active<br/>Workspace
participant R as Reference<br/>Workspace
participant O as Results<br/>Directory
S --> A : Acquire<br/>Lock
activate A
R ->> A : Reset Active<br>Workspace
Note over S,A: Perform session operations, e.g:<br/>gen info files, start Creo,<br/>run FDM, etc..
S --> A : Write "metadata.json"<br/>to Active Workspace
R ->> A : Compare<br/>Workspaces
A ->> O : Write Changed Files<br/>to Result Archive
A --> S : Release<br/>Lock
deactivate A
- Acquire Lock: Each active workspace has a lock that prevents multiple processes and threads from using it at simultaneously. The session acquires the lock for the first available workspace or fails with an error if none are available.
- Reset Workspace: We use
rsync
to make sure the active workspace is a perfect copy of the reference workspace for the various session operations. - Write
metadata.json
: Themetadata.json
file will end up in the result archive, with information about the worker node, the specific workspace being used, and whatever metadata the session was given when it was initialized. - Compare Workspaces: Use
rsync
to get a list of files that have changed relative to the reference workspace. - Write Results: Make zip archive with all the changes and place it in the results directory.
- Release Lock: Allow other sessions or processes to use the workspace again.
The Reference Workspace¶
Run the following to initialize or update the reference workspace:
This shouldn't be run when there are any ongoing sessions.
Provided Sessions¶
There are three basic sessions provided with SimpleUAM, though more can be
added by modifying simple_uam.direct2cad.D2CSession
.
Start Creo¶
Starts Creo and the creoson server on the worker. This is mostly useful for testing, the other sessions that need to start Creo will do it automatically. Run with the following:
A mostly empty result archive will be written to the results directory when the session is finished.
Arguments:
--output=FILE
: Write the output metadata toFILE
. Metadata will be printed to console if not provided.--workspace=NUM
: Use workspaceNUM
if available. The first available workspace will be used if not provided.
Generate Info Files¶
Uses the craidl code to generate info files for a design albeit within a
session that writes the results to an archive in the results directory.
With a design_swri.json
at <design-loc>
, run with:
The output result archive will contain:
metadata.json
: Assorted metadata from this session.design_swri.json
: The design file.info_*.json
: Input files generated by craidl.
Arguments:
--output=FILE
: Write the output metadata toFILE
. Metadata will be printed to console if not provided.--workspace=NUM
: Use workspaceNUM
if available. The first available workspace will be used if not provided.
Process Design¶
This processes an input design with the direct2cad pipeline.
With a design_swri.json
at <design-loc>
, run with:
The output result archive will contain:
- The additional files from
gen-info-files
. - Various CAD files and outputs from the direct2cad pipeline.
buildcad.stdout
: The output stream frombuildCad.py
.buildcad.stderr
: The error stream frombuildCad.py
.
Arguments:
--output=FILE
: Write the output metadata toFILE
. Metadata will be printed to console if not provided.--workspace=NUM
: Use workspaceNUM
if available. The first available workspace will be used if not provided.
Workspace Management¶
Get the cache directory for these workspaces:
Get the root directory of the reference workspace and the live workspaces:
Get the records directory for these workspaces. This is where the zip files with data from each session will go. Run with:
Prune the records directory by deleting old records until only the configured
maximum are present.
It will not delete records that are newer than the
configured min_staletime
.
Run with:
Delete any file system locks that might have gotten left behind. These usually prevent multiple processes from taking control of the same live workspace. Run with: