Manager — Multiflow project manager.

This module defines the ProjectManager class.

class admit.ProjectManager.ProjectManager(baseDirs=[])[source]

Manages parent projects feeding a multiflow project.

Parameters:

baseDirs: list of str

Starting parent project directories.

Notes

Managed projects are numbered sequentially beginning with one. A project ID of zero is reserved for the parent project containing this instance. Individual projects can be accessed by indexing the manager object using the corresponding project ID number.

Attributes

_projects: dict of ADMITs Parent project dictionary, keyed by project ID (a positive integer).
_baseDirs: dict of project base directories Project directory dictionary, keyed by project ID (a positive integer).

Methods

addProject(baseDir) Adds a project.
findTask(pid, isMatch) Finds AT(s) by arbitrary matching criterion.
findTaskAlias(pid, alias) Finds AT(s) by alias.
getProjectDir(pid) Retrieves project base directory given its ID number.
getProjectId(baseDir) Retrieves project ID number given the base directory.
removeProject(pid) Removes a project.
script(py, baseDir[, proj]) Generates a Python script recreating the current project manager.
write() Writes project XML files.
addProject(baseDir)[source]

Adds a project.

The project must be completely up to date to be accepted.

Parameters:

baseDir : str

ADMIT project base directory.

Returns:

int

Project ID number, else -1 if the project was rejected (not up-to-date).

Notes

The up-to-date requirement is a safety feature. Managed projects are assumed to be quasi-static since tasks linked from it must provide valid BDP output at the root of the associated multiflow.

findTask(pid, isMatch)[source]

Finds AT(s) by arbitrary matching criterion.

Parameters:

pid: int

ADMIT project ID number.

isMatch: bool functor(AT)

Match function (returns True/False given an AT argument).

Returns:

list of ATs

ADMIT task reference(s) matching the criterion; may be empty.

findTaskAlias(pid, alias)[source]

Finds AT(s) by alias.

Parameters:

pid: int

ADMIT project ID number.

alias: str

Matching task alias.

Returns:

list of ATs

ADMIT task reference(s) matching the alias; may be empty.

getProjectDir(pid)[source]

Retrieves project base directory given its ID number.

Parameters:

pid: int

Project ID number.

Returns:

str

Project base directory, else None if project not found.

getProjectId(baseDir)[source]

Retrieves project ID number given the base directory.

Parameters:

baseDir: str

Project base directory.

Returns:

int

Project ID number, else -1 if project not found.

removeProject(pid)[source]

Removes a project.

The project should not have any tasks still linked in the multiflow. Verifying this is the responsibility of the caller (multiflow project).

Parameters:

pid : int

Project ID number.

Returns:

bool

True if the project was removed successfully, else False.

Notes

This is a low-level interface not normally called by users.

script(py, baseDir, proj='p')[source]

Generates a Python script recreating the current project manager.

Parameters:

py : file

Open, writable Python file object.

baseDir : str

Master project base directory (ending in ‘/’).

proj : str, optional

Project variable name; defaults to ‘p’.

Returns:

None

Notes

This is a low-level method normally called only by Admit.script().

write()[source]

Writes project XML files.

Project IDs are temporarily reset to zero to avoid polluting the parent project XML files.

Parameters:None
Returns:None

Notes

Parent projects should be rewritten when a multiflow is run in case linked tasks were updated.